Skip to content

Commit

Permalink
move Vector3 and Quaternion createors into Viewer class
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhard-42 committed Jul 5, 2023
1 parent 070c157 commit 10834f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
12 changes: 1 addition & 11 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as THREE from "three";

function clone(obj) {
if (Array.isArray(obj)) {
return obj.map((el) => clone(el));
Expand Down Expand Up @@ -64,12 +62,4 @@ function prettyPrintVector(v, a, b) {
return `${format(v[0], a, b)}, ${format(v[2], a, b)}, ${format(v[2], a, b)}`;
}

function vector3(x = 0, y = 0, z = 0) {
return new THREE.Vector3(x, y, z);
}

function quaternion(x = 0, y = 0, z = 0, w = 1) {
return new THREE.Quaternion(x, y, z, w);
}

export { clone, isEqual, sceneTraverse, prettyPrintVector, vector3, quaternion };
export { clone, isEqual, sceneTraverse, prettyPrintVector };
12 changes: 10 additions & 2 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,8 @@ class Viewer {

const theme =
this.theme === "dark" ||
(this.theme === "browser" &&
window.matchMedia("(prefers-color-scheme: dark)").matches)
(this.theme === "browser" &&
window.matchMedia("(prefers-color-scheme: dark)").matches)
? "dark"
: "light";

Expand Down Expand Up @@ -2014,6 +2014,14 @@ class Viewer {
// update the this
this.update(true);
}

vector3(x = 0, y = 0, z = 0) {
return new THREE.Vector3(x, y, z);
}

quaternion(x = 0, y = 0, z = 0, w = 1) {
return new THREE.Quaternion(x, y, z, w);
}
}

export { Viewer };

0 comments on commit 10834f1

Please sign in to comment.