0

I am working on a bit of a 3d css library that can interact with separately coded Objects with their own logic for whatever program they're needed for. But to display these objects, as they largely only have height, width and depth dimensions, I build a mini 3d css/html engine thingy.

You initialize it with a scene object, which is tied to a html element's id. And that element becomes the scene, then you insert the first object into the scene by going scene.addRootObject(object), this object just needs dimensions, whd, xyz, and it gets rendered, right now I'm only rendering cubes because that's all I need right now. And it will add that object to the scenes list of objects, and also give that object a property called sceneObject which contains the css to create the faces and 3d css elements, the cube class just rotates and positions all faces accordingly to create a cube of any size.

The magic is that I can input dimensions from the real world such as cm, or metres, and the scene, because creating the "root" object, will set a 1 off pixel to irl unit ratio, so the first object receives a width in pixels, proportional to the width of the scene, so it's never larger than the scene width when initializing. You can also put in a "Ratio" which is the ratio of the width of the root object to the width of the scene, so if you put in 80, but 2metres wide and 1 metres tall and 1 metres deep for the rootObject, to a scene that is 1000px wide, your root object will get a width of 800px, but depths and heights will be whatever 800/2 equals, so 400 * 1 will get you the depth. Anyway you need this pixel to irl unit ratio to render the objects.

My point is that I have realised I don't want to restrict the user to manage their custom library objects through my 3d scene object.

What you should instead be able to do is give your libraries object the scene object, or the libraries sceneObject (this is the 3d cube or whatever 3d css is generated by the dimensions of your library object) but if you pass the scene object to all the 3d objects, then you duplicate the scene object a bunch of times and it would be hard on memory, but I can really access the scene object from any of these 3d objects which are properties of external library objects.

Does anyone know how to link a javascript object to a variable so that the variable can be passed to functions, and when edited, actually the edit the data of the object that was passed.

I hope you understand, if not I can fully reword my question. Or provide code. Thank you very much

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
lopu
  • 67
  • 7

0 Answers0