Side effect missing for GreasedLine

Hello,
I am trying to introduce GreasedLine into my application. The application is based on Typescript, I am using ES6 three-shakeable imports and WebGPU.

After importing and using import { CreateGreasedLine } from '@babylonjs/core/Meshes/Builders/greasedLineBuilder';, I get the following runtime error: ERROR engine.rawTexture needs to be imported before as it contains a side-effect required by your code.

I tried importing import '@babylonjs/core/Materials/Textures/rawTexture';, however, the error is not going away.

How to fix it? I assume that there is another import for engine.rawTexture.

Best regards,
Axel

1 Like

cc @roland our GreasedLines semi-god

1 Like

Hi!

This is more like a webpack/vite/whatever question. Which budler do you use?

Here is an example with webpack. This one has no issues:
grl-import-test.zip (2.8 MB)

OR maybe you are after this:

based on this question by you: Missing side effect for CreateLineSystrem - #8 by axeljaeger

Hi @roland,
yes I thought I would be after this, but doing:

import '@babylonjs/core/Engines/Extensions/engine.rawTexture';

before importing CreateGreasedLine unfortunately does not solve the issue while the workaround of

import '@babylonjs/core'

solves the issue at the cost of the bundle size.
I am using this inside an Angular application that uses vite as a builder.

import ā€˜@babylonjs/coreā€™

this works because it imports everything. Read this topic, itā€™s something similar:

Yep and thats what I am trying to avoid. Until the solution is found however, I can at least unblock myself.

Can you share your base project? no src needed.

In fact I can:

To give you a bit of context: The application allows you to chain transformation matrices and visualizes this transformation chain on a canvas. Currently, because the graphics view is broken, you will only see the lower part that is the matrix chain editor.

Best regards,
Axel

1 Like

import '@babylonjs/core/Engines/WebGPU/Extensions/engine.rawTexture';

1 Like

Works, thank you! I deployed a fixed version in case anyone wants to check it out.

2 Likes

Looking good :slight_smile:
Deleting a matrix doesnā€™t work. If I hover over the colored vertical line which result is shown in the 3D view?

You found a bug, deleting should work indeed.

If you hover the line, the smiley corresponding to that part in the transformation chain should be highlighted. It is currently not working. But thats another story: How to use color buffer with GreasedLine and Thin Instances? - #3 by roland