Skip to content

Commit

Permalink
Merge pull request #95 from rdeits/rd/roll-back-threejs
Browse files Browse the repository at this point in the history
Roll back three.js to fix camera animation issues
  • Loading branch information
rdeits authored Aug 29, 2021
2 parents 9b63c6b + f6dc3a9 commit add5031
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion dist/main.min.js

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
"ccapture.js": "aceslowman/ccapture.js#npm-fix",
"dat.gui": "^0.7.7",
"msgpack-lite": "^0.1.26",
"three": "^0.131.1",
"three-wtm": "^1.0",
"wwobjloader2": "^4.0"
"three": "0.122"
},
"scripts": {
"build": "webpack"
Expand Down
10 changes: 6 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ var THREE = require('three');
var msgpack = require('msgpack-lite');
var dat = require('dat.gui').default; // TODO: why is .default needed?
import {BufferGeometryUtils} from 'three/examples/jsm/utils/BufferGeometryUtils.js';
import {OBJLoader2, MtlObjBridge} from 'wwobjloader2'
import {OBJLoader2} from 'three/examples/jsm/loaders/OBJLoader2.js';
import {ColladaLoader} from 'three/examples/jsm/loaders/ColladaLoader.js';
import {MTLLoader} from 'three/examples/jsm/loaders/MTLLoader.js';
import {MtlObjBridge} from 'three/examples/jsm/loaders/obj2/bridge/MtlObjBridge.js';
import {STLLoader} from 'three/examples/jsm/loaders/STLLoader.js';
import {OrbitControls} from 'three/examples/jsm/controls/OrbitControls.js';
require('ccapture.js');
Expand All @@ -20,7 +21,7 @@ function merge_geometries(object, preserve_materials = false) {
function collectGeometries(node, parent_transform) {
let transform = parent_transform.clone().multiply(node.matrix);
if (node.type==='Mesh') {
node.geometry.applyMatrix4(transform);
node.geometry.applyMatrix(transform);
geometries.push(node.geometry);
materials.push(node.material);
}
Expand Down Expand Up @@ -175,7 +176,7 @@ class ExtensibleObjectLoader extends THREE.ObjectLoader {
let mtl_loader = new MTLLoader(manager);
let mtl_parse_result = mtl_loader.parse(json.mtl_library + "\n", "");
let materials = MtlObjBridge.addMaterialsFromMtlLoader(mtl_parse_result);
loader.setMaterials(materials);
loader.addMaterials(materials);
this.onTextureLoad();
}
let obj = loader.parse(json.data + "\n", path);
Expand Down Expand Up @@ -628,7 +629,8 @@ class Animator {
this.progress = 0;
for (let animation of animations) {
let target = this.viewer.scene_tree.find(animation.path).object;
let clip = Object.values(this.loader.parseAnimations([animation.clip]))[0];
let animations = this.loader.parseAnimations([animation.clip]);
let clip = Object.values(animations)[0];
let action = this.mixer.clipAction(clip, target);
action.clampWhenFinished = options.clampWhenFinished;
action.setLoop(options.loopMode, options.repetitions);
Expand Down
23 changes: 21 additions & 2 deletions test/animation.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div id="meshcat-pane">
</div>

<script src="main.min.js"></script>
<script src="main.js"></script>

<script>

Expand Down Expand Up @@ -37,7 +37,26 @@
}]
}]
}
},{
},
{
path: "/Cameras/default/rotated/<object>",
clip: {
fps: 30,
name: "default",
tracks: [{
name: ".zoom",
type: "number",
keys: [{
time: 0,
value: 1
},{
time: 80,
value: 0.5
}]
}]
}
},
{
path: "/meshcat/boxes",
clip: {
fps: 30,
Expand Down
14 changes: 3 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,9 @@ terser@^5.7.0:
source-map "~0.7.2"
source-map-support "~0.5.19"

three-wtm@^1.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/three-wtm/-/three-wtm-1.0.0.tgz#715d1317096de15b87313856befc719c176246d3"

three@^0.131.1:
version "0.131.1"
resolved "https://registry.yarnpkg.com/three/-/three-0.131.1.tgz#c7d35213a0ec5c3ee28316221ecdf2c18d1140a0"
[email protected]:
version "0.122.0"
resolved "https://registry.yarnpkg.com/three/-/three-0.122.0.tgz#bd9ed8a8820074856e8ba7b63fe0a65176e01aeb"

uri-js@^4.2.2:
version "4.4.1"
Expand Down Expand Up @@ -725,10 +721,6 @@ wildcard@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec"

wwobjloader2@^4.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/wwobjloader2/-/wwobjloader2-4.0.0.tgz#61304b2e09db66094a813c156c444af5718e143f"

yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"

0 comments on commit add5031

Please sign in to comment.