Skip to content

Commit f69759a

Browse files
feat: Allow primitives don't add anything to the scene
1 parent 0fd7b3c commit f69759a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/graphics3d.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,17 @@ export default function (
296296
}
297297

298298
// plot the primitives
299-
elements.forEach(
300-
(element) => scene.add(primitiveFunctions[element.type](
299+
elements.forEach((element) => {
300+
const sceneElement = primitiveFunctions[element.type](
301301
element,
302302
uniforms,
303303
/** @type {import('./extent.js').Extent} */(extent),
304304
container
305-
))
306-
);
305+
);
306+
// Primitives like https://mathics3.github.io/mathics-threejs-backend/primitives/text
307+
// don't add anything to the scene, but to the container.
308+
if (sceneElement) scene.add(sceneElement);
309+
});
307310

308311
const renderer = new WebGLRenderer({
309312
antialias: true,

src/primitives/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
* uniforms: import('../uniforms.js').UniformsBuffer,
5959
* extent: import('../extent.js').Extent,
6060
* container: HTMLElement
61-
* ) => import('../../vendors/three.js').Object3D } PrimitiveFunction
61+
* ) => import('../../vendors/three.js').Object3D | null } PrimitiveFunction
6262
*/
6363

6464
// Note that Graphics3D includes a number of 1D and 2D kinds of

0 commit comments

Comments
 (0)