GithubHelp home page GithubHelp logo

Comments (5)

zadvorsky avatar zadvorsky commented on September 26, 2024

Hello.

I just pushed a fix for the actual error, but I'm not sure if you'll be able to re-create your object from JSON. StandardAnimationMaterial (and the other animation materials) all have some extended logic which is not stored in the JSON.

Also, JSON loader has been deprecated. How are you loading / parsing your JSON files?

from three.bas.

martenzander avatar martenzander commented on September 26, 2024

actually I just want to parse the toJSON() Object as a string to compare two instances and debug another error I am currently dealing with. Maybe the error might be related to this.

I am trying to clone the mesh to place it multiple times in my scene at different positions. But if I clone the mesh using the StandardAnimationMaterial(), somehow the shadows break. I also tried to add a new customDepthMaterial to the cloned Mesh, but without success.
Further debugging lead me to the point where I wanted to clone only a BasicAnimationMaterial and here it says:

Uncaught TypeError: Cannot read property 'uniformValues' of undefined

from three.bas.

zadvorsky avatar zadvorsky commented on September 26, 2024

I'm not used to the cloning workflow, so I've never tested it, and I'm not sure what kind of things might break because I don't implement the clone/copy methods on any of the BAS geometries and materials (they just use the method from the THREE.js class they're extending). I can look into adding clone/copy methods, but that may take some time.

If you want to create several meshes, you might be better off either creating a mesh subclass with the geometry and material (like Animation here, and creating instances of that, or working with a factory function.

from three.bas.

martenzander avatar martenzander commented on September 26, 2024

I can look into adding clone/copy methods, but that may take some time.

Don't worry, thanks for all your work on this anyway, very helpful to inject built-in THREE Shaders :).

If you want to create several meshes, you might be better off either creating a mesh subclass with the geometry and material (like Animation here, and creating instances of that, or working with a factory function.

The Subclass thing might be an option and actually is kind of close to the way I work around the problem at the moment. I simply create a new THREE.Mesh() Instance each time I used to clone instead. What do you mean by factory function?

from three.bas.

zadvorsky avatar zadvorsky commented on September 26, 2024

A factory function is just a (pure) function that takes arguments, and returns an object / class instance. Depending on your use case, it can be cleaner than extending Mesh.

Something like:

function createMesh (options) {
 const material = new StandardAnimationMaterial({
  // defaults + material specific options
 }

 const geometry = new PrefabBufferGeometry(
  // prefab, prefab count
 )
 
 const mesh = new Mesh(geometry, material)
 
 return mesh
}

https://en.wikipedia.org/wiki/Factory_method_pattern

This may be what you are already doing though :).

from three.bas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.