Changeset 188 for js/viewer-f0/js/graphicsEngine.js
- Timestamp:
- 03/23/14 12:52:58 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
js/viewer-f0/js/graphicsEngine.js
r143 r188 1 function GraphicsEngine( ) {1 function GraphicsEngine(context) { 2 2 this._scene = undefined; 3 3 this._camera = undefined; 4 4 this._renderer = undefined; 5 this._canvasWidth = 500;6 this._canvasHeight = 500;7 this._containerContext = undefined;5 this._canvasWidth = 400; 6 this._canvasHeight = 400; 7 this._containerContext = context; 8 8 this._BALL_RADIUS = 0.25; 9 9 this._controls = undefined; … … 21 21 this._renderer.setClearColor(0x000000, 1); 22 22 this._renderer.setSize(this._canvasWidth, this._canvasHeight); 23 this._containerContext = $("#container");23 //this._containerContext = $("#container"); 24 24 this._containerContext.append(this._renderer.domElement); 25 25 } … … 43 43 GraphicsEngine.prototype._rotateObject = function (object, part) { 44 44 object.rotateX(part.getXrot()); 45 object.rotateY( part.getYrot());45 object.rotateY(-part.getYrot()); 46 46 object.rotateZ(part.getZrot()); 47 47 } … … 74 74 } 75 75 76 GraphicsEngine.prototype._debugShow = function(object) 77 { 78 var pos = object.position; 79 var scale = object.scale; 80 var rot = object.rotation 81 //console.log(pos.x, pos.y, pos.z , "|", rot.x, rot.y, rot.z,"|", scale.x, scale.y, scale.z); 82 } 83 76 84 GraphicsEngine.prototype._addEllipsoid = function (part) { 77 85 var geometry = new THREE.SphereGeometry(1, 20, 20); 78 geometry.applyMatrix(new THREE.Matrix4().makeScale(part.getXshape(), part.getYshape(), part.getZshape()));79 80 86 var ellipsoidMaterial = new THREE.MeshPhongMaterial({color: 0xffffff}); 81 87 ellipsoidMaterial.color.setRGB(part.getR(), part.getG(), part.getB()) 82 88 83 89 var ellipsoid = new THREE.Mesh(geometry, ellipsoidMaterial); 90 ellipsoid.scale.set(part.getXshape(), part.getYshape(), part.getZshape()) 84 91 ellipsoid.position.set(part.getX(), part.getY(), part.getZ()); 85 92 this._rotateObject(ellipsoid, part); … … 88 95 if(this._showAxis) 89 96 ellipsoid.add(new THREE.AxisHelper(1)); 97 90 98 this._scene.add(ellipsoid); 91 99 } … … 93 101 GraphicsEngine.prototype._addCylinder = function (part) { 94 102 var geometry = new THREE.CylinderGeometry(1, 1, 1, 10, 10, false); 95 geometry.applyMatrix(new THREE.Matrix4().makeScale(part.getZshape(), part.getXshape(), part.getYshape()));96 103 97 104 var material = new THREE.MeshLambertMaterial({color: 0xffffff}); … … 99 106 100 107 var cylinder = new THREE.Mesh(geometry, material); 108 109 cylinder.scale.set(part.getXshape(), part.getYshape(), part.getZshape()) 101 110 cylinder.position.set(part.getX(), part.getY(), part.getZ()); 102 cylinder.overdraw = true;103 111 this._rotateObject(cylinder, part); 104 112 105 113 this._parts.push(cylinder); 106 114 if(this._showAxis) 107 cylinder.add(new THREE.AxisHelper(1)); 115 cylinder.add(new THREE.AxisHelper(5)); 116 108 117 this._scene.add(cylinder); 118 109 119 } 110 120 111 121 GraphicsEngine.prototype._addCuboid = function (part) { 112 122 var geometry = new THREE.CubeGeometry(2, 2, 2, 10, 10, 10); 113 geometry.applyMatrix(new THREE.Matrix4().makeScale(part.getXshape(), part.getYshape(), part.getZshape()));123 //TODO: poprawić getXshape na getXscale 114 124 115 125 var material = new THREE.MeshLambertMaterial({color: 0xffffff}); … … 117 127 118 128 var cube = new THREE.Mesh(geometry, material); 129 cube.scale.set(part.getXshape(), part.getYshape(), part.getZshape()) 119 130 cube.position.set(part.getX(), part.getY(), part.getZ()); 120 131 this._rotateObject(cube, part); … … 127 138 128 139 GraphicsEngine.prototype.addPart = function (part) { 140 console.log(part.getX(),part.getY(),part.getZ(), "|", part.getXshape(),part.getYshape(),part.getZshape(),"|",part.getXrot(),part.getYrot(),part.getZrot()) 129 141 switch (part.getType()) { 130 142 case 0: … … 196 208 197 209 copy.rotateX(joint.getXrot()); 198 copy.rotateY( joint.getYrot());210 copy.rotateY(-joint.getYrot()); 199 211 copy.rotateZ(joint.getZrot()); 200 212 … … 233 245 this._controls = new THREE.TrackballControls(this._camera, this._renderer.domElement) 234 246 this._debug(); 247 248 249 235 250 } 236 251 … … 255 270 GraphicsEngine.prototype.debugTest = function() 256 271 { 257 258 } 259 272 for(var i = 0; i < this._parts.length; i++) 273 this._debugShow(this._parts[i]); 274 } 275
Note: See TracChangeset
for help on using the changeset viewer.