Open GoogleCodeExporter opened 8 years ago
First of all, you should get the obj file loaded in the viewer. When done, the
content of the obj file are wrapped in a Scene object, which can be obtained
via the viewer.getScene()
method(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Viewer.htm
l#getScene).
An obj model might be parsed to multiple meshes, you can get this mesh array
using scene.getChildren()
method(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Scene.html
#getChildren).
Now that you have all the mesh objects, the primitive data are merely plain
properties of these meshes which can be accessed at your will:
mesh.vertexBuffer
mesh.indexBuffer
mesh.texCoordBuffer
mesh.texCoordIndexBuffer
...
Original comment by Humu2...@gmail.com
on 23 Jul 2014 at 3:31
Thanks for reply,but viewer.getScene() returning null,please check the coding
below,is anything wrong?
var canvas = document.getElementById('cv');
var viewer = new JSC3D.Viewer(canvas);
viewer.setParameter('SceneUrl', 'bank/female02.obj');
viewer.setParameter('InitRotationX', 0);
viewer.setParameter('InitRotationY', 0);
viewer.setParameter('InitRotationZ', 0);
viewer.setParameter('MipMapping', 'on');
viewer.setParameter('Renderer', 'webgl');
viewer.init();
viewer.update();
var scene = viewer.getScene();
alert(scene);
Original comment by prasen.b...@gmail.com
on 24 Jul 2014 at 4:49
The loading is asynchronous. So you should override the
viewer.onloadingcomplete(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbol
s/JSC3D.Viewer.html#onloadingcomplete) with a callback function and wrap your
code in it like this:
var viewer = ...
...
viewer.init();
viewer.update();
viewer.onloadingcomplete = function() {
// This will be executed immediately as the loading is done.
var scene = viewer.getScene();
console.info(scene);
...
};
Original comment by Humu2...@gmail.com
on 24 Jul 2014 at 6:20
Ok thanks for your reply,can u please tell me how to load multiple obj file?
Original comment by prasen.b...@gmail.com
on 24 Jul 2014 at 6:39
This discussion http://code.google.com/p/jsc3d/issues/detail?id=52 provides a
good example for how to load multiple models into a single scene.
Please be aware that mutiple models from different sources can be used in a
scene only if they share the same model space. Otherwise there will be a mess.
Original comment by Humu2...@gmail.com
on 24 Jul 2014 at 11:53
Thanks JSC3D is GREAT in the 3D world and project member of JSC3D is the best.
Original comment by prasen.b...@gmail.com
on 24 Jul 2014 at 11:56
How to Change texture of a mesh on a button click?
Original comment by prasen.b...@gmail.com
on 25 Jul 2014 at 10:07
First, get the clicked mesh via mouse event handlers. Then invoke
mesh.setTexture()
method(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Mesh.html#
setTexture) passing in a new texture object to replace the old one. Finally,
call viewer.update() to notify the viewer the scene has changed and update
display. The programming interface of JSC3D.Texture is documented here
http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Texture.html.
Original comment by Humu2...@gmail.com
on 26 Jul 2014 at 2:03
How to change vertexbuffer of a mesh on a button click?
Original comment by prasen.b...@gmail.com
on 30 Jul 2014 at 10:46
Don't change vertexBuffer of an existing mesh. Create a new mesh with the given
vertices and use it to replace the old one.
Original comment by Humu2...@gmail.com
on 31 Jul 2014 at 10:52
ok ,thanks,how to replace a mesh with the old one?
Original comment by prasen.b...@gmail.com
on 31 Jul 2014 at 11:21
Original issue reported on code.google.com by
prasen.b...@gmail.com
on 23 Jul 2014 at 12:21Attachments: