Open GoogleCodeExporter opened 9 years ago
oh, I setParameter again then init & update. It's work
Original comment by fabien...@gmail.com
on 31 Jul 2014 at 10:11
Don't do that. A viewer instance should not be initialized a second time. The
viewer.rotate() method
http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Viewer.html#rotat
e is provided for this purpose. Call viewer.rotate(), passing in the rotation
angles and it will be ok.
Original comment by Humu2...@gmail.com
on 31 Jul 2014 at 11:05
I tried rotate but it not work
var canvas = document.getElementById('cv');
var viewer = new JSC3D.Viewer(canvas);
viewer.setParameter('SceneUrl', 'bank/Western_Bank.obj');
viewer.setParameter('InitRotationX', 0);
viewer.setParameter('InitRotationY', 0);
viewer.setParameter('InitRotationZ', 0);
viewer.setParameter('ModelColor', '#CAA618');
viewer.setParameter('BackgroundColor1', '#E5D7BA');
viewer.setParameter('BackgroundColor2', '#383840');
viewer.setParameter('RenderMode', 'textureflat');
viewer.setParameter('MipMapping', 'on');
viewer.setParameter('Renderer', 'webgl');
viewer.init();
viewer.update();
$('#change-obj').click(function(){
viewer.replaceSceneFromUrl('bank/Western_Bank_2.obj');
viewer.rotate(45,45,45);
viewer.update();
})
if no replaceSceneFromUrl => it work & each click obj model rotate 45 45 45.
I want new obj model (replaceSceneFromUrl) has rotate only 45 45 45. I try
setParameter again then init & update. It's work
Original comment by fabien...@gmail.com
on 1 Aug 2014 at 1:25
viewer.rotate() makes incremental rotations. I guess you should save the
current rotation angles before call of viewer.replaceSceneFromUrl() and then
restore them using viewer.rotate().
Original comment by Humu2...@gmail.com
on 1 Aug 2014 at 2:05
I set:
viewer.setParameter('SceneUrl', 'bank/Western_Bank.obj');
viewer.setParameter('InitRotationX', 0);
viewer.setParameter('InitRotationY', 0);
viewer.setParameter('InitRotationZ', 0);
$('#change-obj').click(function(){
var rotationAngles = viewer.getRotationAngles();
viewer.replaceSceneFromUrl('bank/Western_Bank_2.obj');
viewer.rotate(rotationAngles[0],rotationAngles[1],rotationAngles[2]);
viewer.update();
})
but not work. Rotation is 0 0 0 although I rotation objModel to new rotation
I set:
$('#change-obj').click(function(){
var rotationAngles = viewer.getRotationAngles();
viewer.replaceSceneFromUrl('bank/Western_Bank_2.obj');
viewer.setParameter('InitRotationX', rotationAngles[0]);
viewer.setParameter('InitRotationY', rotationAngles[1]);
viewer.setParameter('InitRotationZ', rotationAngles[2]);
viewer.init();
viewer.update(false);
})
It't work
Original comment by fabien...@gmail.com
on 1 Aug 2014 at 2:15
I'm afraid you forget the loading is asynchronous. When you call
viewer.replaceSceneFromUrl(), it won't be done immediately. The correct method
is to utilize the callback mechanism, overriding viewer.onloadingcomplete
(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Viewer.html#onlo
adingcomplete) to defer the rotation until the new model is loaded suceessfully:
viewer.replaceSceneFromUrl(...);
viewer.onloadingcomplete = function() {
viewer.rotate(...);
viewer.update();
};
That's it.
Original comment by Humu2...@gmail.com
on 1 Aug 2014 at 3:19
Yes. Thank you. Rotation it work. But each click, it makes INCREMENTAL
rotations.
How to reset this to 0 0 0 then resume rotate with rotation current?
Original comment by fabien...@gmail.com
on 1 Aug 2014 at 3:28
Because I set
viewer.setParameter('InitRotationX', 45);
viewer.setParameter('InitRotationY', 45);
viewer.setParameter('InitRotationZ', 30);
not 0 0 0 => each click, objModel will INCREMENTAL rotation, not resume
Original comment by fabien...@gmail.com
on 1 Aug 2014 at 3:34
[deleted comment]
I see. Try to add this new function to jsc3d.js and use it instead of rotate()
then:
JSC3D.Viewer.prototype.setRotations = function(rotX, rotY, rotZ) {
this.rotMatrix.identity();
this.rotMatrix.rotateAboutXAxis(rotX);
this.rotMatrix.rotateAboutYAxis(rotY);
this.rotMatrix.rotateAboutZAxis(rotZ);
};
It resets the rotation matrix and apply the given rotations on an identity one.
Original comment by Humu2...@gmail.com
on 1 Aug 2014 at 9:55
Thank you so much. It's work very well
Original comment by fabien...@gmail.com
on 2 Aug 2014 at 4:55
Hello,
I am new at jsc3d, can you show me how to set to the fixed position on click
event, when the object is at any axis.
I mean to say, when click event is trigger it should bring to (0,0,0) with
slight animated motion.
Please with some detailed example as I am in learning phase.
Thanks in advance
Original comment by ruchir.k...@gmail.com
on 19 Feb 2015 at 7:20
Original issue reported on code.google.com by
fabien...@gmail.com
on 31 Jul 2014 at 9:48