I’m trying to understand the code under this example: instancing/scatter as found on github
Reproducing it is working quite fine, but I came upon an error and realised I do not understand a part that is happening here:
Why is the loaded geometry copied to prototype?
Is the geometry type being casted here? Why?
Also, I’ve never encountered
.prototype.copy,call method, is it like
Thanks for explaining, preferably in simple words
By the way, the error I get is
I would like to understand better the logic and methods before I troubleshoot it (unless you may have any idea).
The geometry of
_blossomMesh are of type
blossomGeometry are of a more specific type
InstancedBufferGeometry. You could write the code like so:
stemGeometry.copy( _stemMesh.geometry );
blossomGeometry.copy( _blossomMesh.geometry );
copy() method of
InstancedBufferGeometry would copy and
undefined value to
BufferGeometry does not have the property
I suggest you study a bit the semantics of Function.prototype.call() then this approach will become clear. In this particular use case, the syntax
THREE.BufferGeometry.prototype.copy.call() means we call
BufferGeometry.copy() in context of
this points to
_stemMesh.geometry as the methods actual parameter. In some sense, it’s like calling the super method of