question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding prefix to Object3D id

See original GitHub issue

Using 2 different libraries (A and B) based on threejs.

Each library generates valid threejs meshes independently. However, the id of the meshes from library A and B can conflict (i.e. be the same). Then when we add meshes from library A and B into the same scene it does not render properly.

Is there a mechanism we can use to generate meshes independently and ensure IDs do not conflict while rendering it in the same scene?

One idea is to add a prefix concept:

Object.defineProperty( this, 'id', { value: object3DId ++ } );
=>
Object.defineProperty( this, 'id', { value: `${prefix}-${object3DId ++}` } );

Not quite sure which would be the best way to pass the prefix though.

Any thoughts on that?

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:26 (22 by maintainers)

github_iconTop GitHub Comments

3reactions
haroldiedemacommented, Jun 5, 2018

Sure, lets say you have a global namespace THREE, now if your App A sets a property value THREE.generator to X and your app B sets a property value for the same property to Y - only one of those will actually stick.

Now I think about it, I think you have bigger problems if there are actually multiple instances of THREE loaded in your app. If you manage to let both libraries use the same instance, then your problems will also be gone. I would suggest trying this instead of “hacking” around the ID generation.

2reactions
NicolasRannoucommented, Jun 26, 2018

FYI - I fixed ami to work nicely with different version of three using a factory pattern. We can close the issue or keep it open if you think such a feature (prefix id) may be useful at some point.

//
import * as THREE from 'three';
import {customHelperFactory} from 'ami';

const CustomHelper = customHelperFactory(THREE);
const helper = new CustomHelper();
scene.add(helper);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Get an Object by name not id in three.js
This is a post on the name property of the object3d class in three.js that is an empty string by default, but can...
Read more >
Object3D#name – three.js docs
Object3D. This is the base class for most objects in three.js and provides a set of properties and methods for manipulating objects in...
Read more >
org.rajawali3d.Object3D.getName java code examples
How to use. getName. method. in. org.rajawali3d.Object3D ... getName()); currentObjHasFaces = false; objIndices.add(currObjIndexData); currObjIndexData ...
Read more >
ID Prefix Settings - Tricentis
To customize ID Prefixes, you need the Manage Project Settings permission. Select the Gear icon, and select ID Prefix Settings. The ID Prefix...
Read more >
How to set the object prefix in DOORS - IBM
The Object Identifier is composed of the Module Prefix concatenated with the Object's ... Add your desired prefix in the value field
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found