Typecast fails if `getObjectByName` method returns objects other than Object3D
See original GitHub issuePlease refer the example mentioned below:
const scene = new THREE.scene()
const upperPlaneCloudMaterial = new THREE.PointsMaterial({
vertexColors: THREE.VertexColors,
size: 0.08,
clippingPlanes: []
})
const pointsObject = new THREE.Points(this.cloudGeometry, upperPlaneCloudMaterial)
const pointsObject.name = 'pointsObject'
scene.add(this.cloudField)
Now while getting cloud field by method getObjectByName()
const pointsObject = scene.getObjectByName('pointsObject')
pointsObject.geometry.attributes.position.needsUpdate = true
pointsObject.geometry.attributes.position.setArray(attributesData.position)
pointsObject.geometry.computeBoundingSphere()
It gives type error as mentioned below:
Property 'geometry' does not exist on type 'Object3D'
Three.js version
- Dev
- r115
- …
Browser
- All of them
- Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Object3D#getObjectByName – three.js docs
Object gets rendered if true . Default is true . Static Properties. Static properties and methods are defined per class rather than per...
Read more >Three JS. "Property 'material' does not exist on type 'Object3D ...
I think the problem is that the return type of getObjectByName() is Object3D . And objects of this type do not have a...
Read more >JavaScript type casting gone wrong | by Glad Chinda
When casting JavaScript values to strings, especially objects, ... The createSalaryObject() function returns a custom JavaScript object that ...
Read more >Object Type Casting in Java - Baeldung
An overview of type casting in Java, covered with simple and easy to ... There's another way to cast objects using the methods...
Read more >Casting and runtime type checking (using instanceof)
When the return value of a method is an interface type, the method ... the same method can work with many different underlying...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t see a cast in your code above — does this also fail to compile in TypeScript?
Yes we can close this issue now