matrix-engine-wgpu 1.0.6 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codesandbox/tasks.json +46 -0
- package/.devcontainer/devcontainer.json +22 -0
- package/.github/dependabot.yml +12 -0
- package/REFERENCE.md +3 -5
- package/dev.md +460 -0
- package/empty.js +7 -6
- package/examples/games/jamb/jamb.js +1133 -0
- package/examples/load-obj-file.js +65 -28
- package/examples/unlit-textures.js +26 -23
- package/examples.js +35 -3
- package/index.js +8 -2
- package/main.js +454 -48
- package/non-project-files/dev.txt +21 -0
- package/non-project-files/image1.png +0 -0
- package/non-project-files/image6.png +0 -0
- package/package.json +31 -13
- package/public/app.js +2234 -114
- package/public/css/style.css +371 -110
- package/public/empty.html +1 -1
- package/public/empty.js +9887 -9264
- package/public/examples.html +10 -8
- package/public/examples.js +2035 -247
- package/public/index.html +3 -5
- package/public/manifest copy.web +35 -0
- package/public/res/audios/block.mp3 +0 -0
- package/public/res/audios/dice1.mp3 +0 -0
- package/public/res/audios/dice2.mp3 +0 -0
- package/public/res/audios/start.mp3 +0 -0
- package/public/res/meshes/jamb/bg.blend +0 -0
- package/public/res/meshes/jamb/bg.blend1 +0 -0
- package/public/res/meshes/jamb/bg.mtl +12 -0
- package/public/res/meshes/jamb/bg.obj +17 -0
- package/public/res/meshes/jamb/bg.png +0 -0
- package/public/res/meshes/jamb/dice-default.png +0 -0
- package/public/res/meshes/jamb/dice-mark.png +0 -0
- package/public/res/meshes/jamb/dice.mtl +12 -0
- package/public/res/meshes/jamb/dice.obj +40 -0
- package/public/res/meshes/jamb/dice.png +0 -0
- package/public/res/meshes/jamb/jamb-title.mtl +12 -0
- package/public/res/meshes/jamb/jamb-title.obj +26008 -0
- package/public/res/meshes/jamb/jamb.blend +0 -0
- package/public/res/meshes/jamb/jamb.blend1 +0 -0
- package/public/res/meshes/jamb/logo.png +0 -0
- package/public/res/meshes/jamb/nidzaDice.blend +0 -0
- package/public/res/meshes/jamb/nidzaDice.blend1 +0 -0
- package/public/res/meshes/jamb/pile.blend +0 -0
- package/public/res/meshes/jamb/simpleCube.blend +0 -0
- package/public/res/meshes/jamb/simpleCube.blend1 +0 -0
- package/public/res/meshes/jamb/sounds/roll1.wav +0 -0
- package/public/res/meshes/jamb/text.png +0 -0
- package/public/res/multilang/en.json +27 -0
- package/public/res/multilang/sr.json +27 -0
- package/public/test.html +636 -0
- package/public/three-test.js +165 -0
- package/public/worker.html +1 -1
- package/readme.md +193 -115
- package/src/engine/ball.js +477 -468
- package/src/engine/cube.js +486 -468
- package/src/engine/engine.js +4 -6
- package/src/engine/loader-obj.js +9 -6
- package/src/engine/matrix-class.js +237 -204
- package/src/engine/mesh-obj.js +603 -515
- package/src/engine/raycast.js +101 -0
- package/src/engine/utils.js +69 -3
- package/src/multilang/lang.js +35 -0
- package/src/physics/matrix-ammo.js +168 -15
- package/src/shaders/fragment.wgsl.js +4 -2
- package/src/shaders/shaders.js +1 -1
- package/src/shaders/vertexShadow.wgsl.js +1 -1
- package/src/sounds/sounds.js +47 -0
- package/src/world.js +311 -248
package/src/engine/engine.js
CHANGED
|
@@ -164,7 +164,9 @@ export class WASDCamera extends CameraBase {
|
|
|
164
164
|
const position = vec3.copy(this.position);
|
|
165
165
|
|
|
166
166
|
// Reconstruct the camera's rotation, and store into the camera matrix.
|
|
167
|
-
super.matrix = mat4.rotateX(mat4.rotationY(this.yaw), this.pitch);
|
|
167
|
+
super.matrix = mat4.rotateX(mat4.rotationY(this.yaw), this.pitch);
|
|
168
|
+
// super.matrix = mat4.rotateX(mat4.rotationY(this.yaw), -this.pitch);
|
|
169
|
+
// super.matrix = mat4.rotateY(mat4.rotateX(this.pitch), this.yaw);
|
|
168
170
|
|
|
169
171
|
// Calculate the new target velocity
|
|
170
172
|
const digital = input.digital;
|
|
@@ -337,9 +339,7 @@ function lerp(a, b, s) {
|
|
|
337
339
|
return vec3.addScaled(a, vec3.sub(b, a), s);
|
|
338
340
|
}
|
|
339
341
|
|
|
340
|
-
//
|
|
341
|
-
|
|
342
|
-
// // Input holds as snapshot of input state
|
|
342
|
+
// Input holds as snapshot of input state
|
|
343
343
|
// export default interface Input {
|
|
344
344
|
// // Digital input (e.g keyboard state)
|
|
345
345
|
// readonly digital: {
|
|
@@ -358,10 +358,8 @@ function lerp(a, b, s) {
|
|
|
358
358
|
// readonly touching: boolean;
|
|
359
359
|
// };
|
|
360
360
|
// }
|
|
361
|
-
|
|
362
361
|
// InputHandler is a function that when called, returns the current Input state.
|
|
363
362
|
// export type InputHandler = () => Input;
|
|
364
|
-
|
|
365
363
|
// createInputHandler returns an InputHandler by attaching event handlers to the window and canvas.
|
|
366
364
|
export function createInputHandler(window, canvas) {
|
|
367
365
|
let digital = {
|
package/src/engine/loader-obj.js
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* information can then be used later on when creating your VBOs. See
|
|
5
5
|
* OBJ.initMeshBuffers for an example of how to use the newly created Mesh
|
|
6
6
|
*
|
|
7
|
+
* Nidza Note:
|
|
8
|
+
* There is difference from me source obj loader and me-wgpu obj loader
|
|
9
|
+
* Here we need scele in comp x,y,z because we use also primitive [cube, sphere etc...]
|
|
7
10
|
* @class Mesh
|
|
8
11
|
* @constructor
|
|
9
12
|
*
|
|
@@ -21,7 +24,7 @@ export class constructMesh {
|
|
|
21
24
|
this.create(this.objectData, this.inputArg)
|
|
22
25
|
};
|
|
23
26
|
this.updateBuffers = () => {
|
|
24
|
-
this.inputArg.scale = 1;
|
|
27
|
+
this.inputArg.scale = [0.1,0.1,0.1];
|
|
25
28
|
this.create(this.objectData, this.inputArg);
|
|
26
29
|
};
|
|
27
30
|
}
|
|
@@ -184,9 +187,9 @@ export class constructMesh {
|
|
|
184
187
|
This same process is repeated for verts and textures.
|
|
185
188
|
*/
|
|
186
189
|
// vertex position
|
|
187
|
-
unpacked.verts.push(+verts[(vertex[0] - 1) * 3 + initOrientation[0]] * inputArg.scale);
|
|
188
|
-
unpacked.verts.push(+verts[(vertex[0] - 1) * 3 + initOrientation[1]] * inputArg.scale);
|
|
189
|
-
unpacked.verts.push(+verts[(vertex[0] - 1) * 3 + initOrientation[2]] * inputArg.scale);
|
|
190
|
+
unpacked.verts.push(+verts[(vertex[0] - 1) * 3 + initOrientation[0]] * inputArg.scale[0]);
|
|
191
|
+
unpacked.verts.push(+verts[(vertex[0] - 1) * 3 + initOrientation[1]] * inputArg.scale[1]);
|
|
192
|
+
unpacked.verts.push(+verts[(vertex[0] - 1) * 3 + initOrientation[2]] * inputArg.scale[2]);
|
|
190
193
|
|
|
191
194
|
// vertex textures
|
|
192
195
|
if (textures.length) {
|
|
@@ -263,11 +266,11 @@ export var downloadMeshes = function (nameAndURLs, completionCallback, inputArg)
|
|
|
263
266
|
// a new object is created. this will be passed into the completionCallback
|
|
264
267
|
if (typeof inputArg === 'undefined') {
|
|
265
268
|
var inputArg = {
|
|
266
|
-
scale: 1,
|
|
269
|
+
scale: [0.1,0.1,0.1],
|
|
267
270
|
swap: [null]
|
|
268
271
|
};
|
|
269
272
|
}
|
|
270
|
-
if (typeof inputArg.scale === 'undefined') inputArg.scale = 0.1;
|
|
273
|
+
if (typeof inputArg.scale === 'undefined') inputArg.scale = [0.1,0.1,0.1];
|
|
271
274
|
if (typeof inputArg.swap === 'undefined') inputArg.swap = [null];
|
|
272
275
|
|
|
273
276
|
var meshes = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {degToRad} from "./utils";
|
|
1
|
+
import {degToRad, radToDeg} from "./utils";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @description
|
|
@@ -8,212 +8,245 @@ import {degToRad} from "./utils";
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export class Position {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
11
|
+
constructor(x, y, z) {
|
|
12
|
+
// console.log('TEST TYTPOF ', x)
|
|
13
|
+
// Not in use for nwo this is from matrix-engine project [nameUniq]
|
|
14
|
+
this.nameUniq = null;
|
|
15
|
+
|
|
16
|
+
if(typeof x == 'undefined') x = 0;
|
|
17
|
+
if(typeof y == 'undefined') y = 0;
|
|
18
|
+
if(typeof z == 'undefined') z = 0;
|
|
19
|
+
|
|
20
|
+
this.x = parseFloat(x);
|
|
21
|
+
this.y = parseFloat(y);
|
|
22
|
+
this.z = parseFloat(z);
|
|
23
|
+
|
|
24
|
+
this.velY = 0;
|
|
25
|
+
this.velX = 0;
|
|
26
|
+
this.velZ = 0;
|
|
27
|
+
this.inMove = false;
|
|
28
|
+
this.targetX = parseFloat(x);
|
|
29
|
+
this.targetY = parseFloat(y);
|
|
30
|
+
this.targetZ = parseFloat(z);
|
|
31
|
+
this.thrust = 0.01;
|
|
32
|
+
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setSpeed(n) {
|
|
37
|
+
if(typeof n === 'number') {
|
|
38
|
+
this.thrust = n;
|
|
39
|
+
} else {
|
|
40
|
+
console.log('Description: arguments (w, h) must be type of number.');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
translateByX(x) {
|
|
45
|
+
this.inMove = true;
|
|
46
|
+
this.targetX = parseFloat(x);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
translateByY(y) {
|
|
50
|
+
this.inMove = true;
|
|
51
|
+
this.targetY = parseFloat(y);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
translateByZ(z) {
|
|
55
|
+
this.inMove = true;
|
|
56
|
+
this.targetZ = parseFloat(z);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
translateByXY(x, y) {
|
|
60
|
+
this.inMove = true;
|
|
61
|
+
this.targetX = parseFloat(x);
|
|
62
|
+
this.targetY = parseFloat(y);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
translateByXZ(x, z) {
|
|
66
|
+
this.inMove = true;
|
|
67
|
+
this.targetX = parseFloat(x);
|
|
68
|
+
this.targetZ = parseFloat(z);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
translateByYZ(y, z) {
|
|
72
|
+
this.inMove = true;
|
|
73
|
+
this.targetY = parseFloat(y);
|
|
74
|
+
this.targetZ = parseFloat(z);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
onTargetPositionReach() {}
|
|
78
|
+
|
|
79
|
+
update() {
|
|
80
|
+
var tx = parseFloat(this.targetX) - parseFloat(this.x),
|
|
81
|
+
ty = parseFloat(this.targetY) - parseFloat(this.y),
|
|
82
|
+
tz = parseFloat(this.targetZ) - parseFloat(this.z),
|
|
83
|
+
dist = Math.sqrt(tx * tx + ty * ty + tz * tz);
|
|
84
|
+
this.velX = (tx / dist) * this.thrust;
|
|
85
|
+
this.velY = (ty / dist) * this.thrust;
|
|
86
|
+
this.velZ = (tz / dist) * this.thrust;
|
|
87
|
+
if(this.inMove == true) {
|
|
88
|
+
if(dist > this.thrust) {
|
|
89
|
+
this.x += this.velX;
|
|
90
|
+
this.y += this.velY;
|
|
91
|
+
this.z += this.velZ;
|
|
92
|
+
|
|
93
|
+
// // from me
|
|
94
|
+
// if(net && net.connection && typeof em === 'undefined' && App.scene[this.nameUniq].net.enable == true) net.connection.send({
|
|
95
|
+
// netPos: {x: this.x, y: this.y, z: this.z},
|
|
96
|
+
// netObjId: this.nameUniq,
|
|
97
|
+
// });
|
|
98
|
+
|
|
99
|
+
} else {
|
|
100
|
+
this.x = this.targetX;
|
|
101
|
+
this.y = this.targetY;
|
|
102
|
+
this.z = this.targetZ;
|
|
103
|
+
this.inMove = false;
|
|
104
|
+
this.onTargetPositionReach();
|
|
105
|
+
|
|
106
|
+
// // from me
|
|
107
|
+
// if(net && net.connection && typeof em === 'undefined' && App.scene[this.nameUniq].net.enable == true) net.connection.send({
|
|
108
|
+
// netPos: {x: this.x, y: this.y, z: this.z},
|
|
109
|
+
// netObjId: this.nameUniq,
|
|
110
|
+
// });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get worldLocation() {
|
|
116
|
+
return [parseFloat(this.x), parseFloat(this.y), parseFloat(this.z)];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
SetX(newx, em) {
|
|
120
|
+
this.x = newx;
|
|
121
|
+
this.targetX = newx;
|
|
122
|
+
this.inMove = false;
|
|
123
|
+
|
|
124
|
+
// if(net && net.connection && typeof em === 'undefined' &&
|
|
125
|
+
// App.scene[this.nameUniq].net && App.scene[this.nameUniq].net.enable == true) {
|
|
126
|
+
// net.connection.send({
|
|
127
|
+
// netPos: {x: this.x, y: this.y, z: this.z},
|
|
128
|
+
// netObjId: this.nameUniq,
|
|
129
|
+
// });
|
|
130
|
+
// }
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
SetY(newy, em) {
|
|
134
|
+
this.y = newy;
|
|
135
|
+
this.targetY = newy;
|
|
136
|
+
this.inMove = false;
|
|
137
|
+
// if(net && net.connection && typeof em === 'undefined' &&
|
|
138
|
+
// App.scene[this.nameUniq].net && App.scene[this.nameUniq].net.enable == true) net.connection.send({
|
|
139
|
+
// netPos: {x: this.x, y: this.y, z: this.z},
|
|
140
|
+
// netObjId: this.nameUniq,
|
|
141
|
+
// });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
SetZ(newz, em) {
|
|
145
|
+
this.z = newz;
|
|
146
|
+
this.targetZ = newz;
|
|
147
|
+
this.inMove = false;
|
|
148
|
+
// if(net && net.connection && typeof em === 'undefined' &&
|
|
149
|
+
// App.scene[this.nameUniq].net && App.scene[this.nameUniq].net.enable == true) net.connection.send({
|
|
150
|
+
// netPos: {x: this.x, y: this.y, z: this.z},
|
|
151
|
+
// netObjId: this.nameUniq,
|
|
152
|
+
// });
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
get X() {
|
|
156
|
+
return parseFloat(this.x)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
get Y() {
|
|
160
|
+
return parseFloat(this.y)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
get Z() {
|
|
164
|
+
return parseFloat(this.z)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
setPosition(newx, newy, newz) {
|
|
168
|
+
this.x = newx;
|
|
169
|
+
this.y = newy;
|
|
170
|
+
this.z = newz;
|
|
171
|
+
this.targetX = newx;
|
|
172
|
+
this.targetY = newy;
|
|
173
|
+
this.targetZ = newz;
|
|
174
|
+
this.inMove = false;
|
|
175
|
+
|
|
176
|
+
// from me
|
|
177
|
+
// if(App.scene[this.nameUniq] && net && net.connection && typeof em === 'undefined' &&
|
|
178
|
+
// App.scene[this.nameUniq].net && App.scene[this.nameUniq].net.enable == true) net.connection.send({
|
|
179
|
+
// netPos: {x: this.x, y: this.y, z: this.z},
|
|
180
|
+
// netObjId: this.nameUniq,
|
|
181
|
+
// });
|
|
182
|
+
}
|
|
172
183
|
}
|
|
173
184
|
|
|
174
185
|
export class Rotation {
|
|
175
186
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
187
|
+
constructor(x, y, z) {
|
|
188
|
+
// Not in use for nwo this is from matrix-engine project [nameUniq]
|
|
189
|
+
this.nameUniq = null;
|
|
190
|
+
if(typeof x == 'undefined') x = 0;
|
|
191
|
+
if(typeof y == 'undefined') y = 0;
|
|
192
|
+
if(typeof z == 'undefined') z = 0;
|
|
193
|
+
this.x = x;
|
|
194
|
+
this.y = y;
|
|
195
|
+
this.z = z;
|
|
196
|
+
this.rotationSpeed = {x: 0, y: 0, z: 0};
|
|
197
|
+
this.angle = 0;
|
|
198
|
+
this.axis = {x: 0, y: 0, z: 0};
|
|
199
|
+
// not in use good for exstend logic
|
|
200
|
+
this.matrixRotation = null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
toDegree() {
|
|
204
|
+
|
|
205
|
+
/*
|
|
206
|
+
heading = atan2(y * sin(angle)- x * z * (1 - cos(angle)) , 1 - (y2 + z2 ) * (1 - cos(angle)))
|
|
207
|
+
attitude = asin(x * y * (1 - cos(angle)) + z * sin(angle))
|
|
208
|
+
bank = atan2(x * sin(angle)-y * z * (1 - cos(angle)) , 1 - (x2 + z2) * (1 - cos(angle)))
|
|
209
|
+
*/
|
|
210
|
+
return [radToDeg(this.axis.x), radToDeg(this.axis.y), radToDeg(this.axis.z)];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
toDegreeX() {
|
|
214
|
+
return Math.cos(radToDeg(this.axis.x) / 2)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
toDegreeY() {
|
|
218
|
+
return Math.cos(radToDeg(this.axis.z) / 2)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
toDegreeZ() {
|
|
222
|
+
return Math.cos(radToDeg(this.axis.y) / 2)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
getRotX() {
|
|
226
|
+
if(this.rotationSpeed.x == 0) {
|
|
227
|
+
return degToRad(this.x);
|
|
228
|
+
} else {
|
|
229
|
+
this.x = this.x + this.rotationSpeed.x * 0.001;
|
|
230
|
+
return degToRad(this.x);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
getRotY() {
|
|
235
|
+
if(this.rotationSpeed.y == 0) {
|
|
236
|
+
return degToRad(this.y);
|
|
237
|
+
} else {
|
|
238
|
+
this.y = this.y + this.rotationSpeed.y * 0.001;
|
|
239
|
+
return degToRad(this.y);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
getRotZ() {
|
|
244
|
+
if(this.rotationSpeed.z == 0) {
|
|
245
|
+
return degToRad(this.z);
|
|
246
|
+
} else {
|
|
247
|
+
this.z = this.z + this.rotationSpeed.z * 0.001;
|
|
248
|
+
return degToRad(this.z);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
218
251
|
|
|
219
252
|
}
|