mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-03-19 17:01:55 +08:00
Motion trail and general performance improvements
This commit is contained in:
parent
f4415e1e06
commit
537795730d
@ -1244,8 +1244,7 @@ const Animator = {
|
||||
|
||||
for (var time = start_time; time <= max_time; time += step) {
|
||||
displayTime(time);
|
||||
let position = new THREE.Vector3().copy(target.mesh.position);
|
||||
target.mesh.localToWorld(position);
|
||||
let position = THREE.fastWorldPosition(target.mesh, new THREE.Vector3());
|
||||
geometry.vertices.push(position);
|
||||
}
|
||||
|
||||
@ -1265,7 +1264,6 @@ const Animator = {
|
||||
mesh.position.copy(vertex);
|
||||
Animator.motion_trail.add(mesh);
|
||||
})
|
||||
console.log('trail')
|
||||
},
|
||||
preview() {
|
||||
// Bones
|
||||
|
@ -524,6 +524,7 @@ const Timeline = {
|
||||
}
|
||||
},
|
||||
pause() {
|
||||
Animator.preview();
|
||||
Timeline.playing = false;
|
||||
BarItems.play_animation.setIcon('play_arrow')
|
||||
if (Timeline.interval) {
|
||||
|
@ -531,7 +531,7 @@ class Cube extends NonGroup {
|
||||
if (m) {
|
||||
var r = m.getWorldQuaternion(new THREE.Quaternion())
|
||||
pos.applyQuaternion(r)
|
||||
pos.add(m.getWorldPosition(new THREE.Vector3()))
|
||||
pos.add(THREE.fastWorldPosition(m, new THREE.Vector3()))
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class Locator extends NonGroup {
|
||||
var pos = new THREE.Vector3();
|
||||
var q = new THREE.Quaternion();
|
||||
if (this.parent instanceof Group) {
|
||||
this.parent.mesh.getWorldPosition(pos);
|
||||
THREE.fastWorldPosition(this.parent.mesh, pos);
|
||||
this.parent.mesh.getWorldQuaternion(q);
|
||||
var offset2 = new THREE.Vector3().fromArray(this.parent.origin).applyQuaternion(q);
|
||||
pos.sub(offset2);
|
||||
|
@ -296,7 +296,7 @@ const Canvas = {
|
||||
|
||||
var line = Canvas.getOutlineMesh(mesh)
|
||||
|
||||
mesh.getWorldPosition(line.position)
|
||||
THREE.fastWorldPosition(mesh, line.position)
|
||||
line.position.sub(scene.position)
|
||||
line.rotation.setFromQuaternion(mesh.getWorldQuaternion(new THREE.Quaternion()))
|
||||
mesh.getWorldScale(line.scale)
|
||||
@ -478,44 +478,6 @@ const Canvas = {
|
||||
}
|
||||
geometry.elementsNeedUpdate = true;
|
||||
},
|
||||
ascendElementPosition(el, elmesh) {
|
||||
function iterate(obj, mesh) {
|
||||
//Iterate inside (cube) > outside
|
||||
if (!mesh) {
|
||||
mesh = obj.mesh
|
||||
}
|
||||
if (obj.type === 'group') {
|
||||
mesh.rotation.reorder('ZYX')
|
||||
obj.rotation.forEach(function(n, i) {
|
||||
mesh.rotation[getAxisLetter(i)] = Math.PI / (180 / n) * (i == 2 ? -1 : 1)
|
||||
})
|
||||
mesh.updateMatrixWorld()
|
||||
}
|
||||
mesh.fix_rotation = mesh.rotation.clone()
|
||||
|
||||
if (obj.type === 'group') {
|
||||
mesh.position.fromArray(obj.origin)
|
||||
mesh.scale.x = mesh.scale.y = mesh.scale.z = 1
|
||||
}
|
||||
|
||||
if (typeof obj.parent === 'object') {
|
||||
|
||||
mesh.position.x -= obj.parent.origin[0]
|
||||
mesh.position.y -= obj.parent.origin[1]
|
||||
mesh.position.z -= obj.parent.origin[2]
|
||||
}
|
||||
mesh.fix_position = mesh.position.clone()
|
||||
|
||||
if (typeof obj.parent === 'object') {
|
||||
var parent_mesh = iterate(obj.parent)
|
||||
parent_mesh.add(mesh)
|
||||
} else {
|
||||
scene.add(mesh)
|
||||
}
|
||||
return mesh
|
||||
}
|
||||
iterate(el, elmesh)
|
||||
},
|
||||
getLayeredMaterial(layers) {
|
||||
if (Canvas.layered_material && !layers) return Canvas.layered_material;
|
||||
// https://codepen.io/Fyrestar/pen/YmpXYr
|
||||
|
@ -242,3 +242,13 @@ THREE.GridHelper = class GridHelper extends THREE.LineSegments {
|
||||
THREE.NormalX = new THREE.Vector3(1, 0, 0);
|
||||
THREE.NormalY = new THREE.Vector3(0, 1, 0);
|
||||
THREE.NormalZ = new THREE.Vector3(0, 0, 1);
|
||||
|
||||
THREE.fastWorldPosition = (object, vec) => {
|
||||
if (!vec) {
|
||||
vec = new THREE.Vector3();
|
||||
} else {
|
||||
vec.set(0, 0, 0);
|
||||
}
|
||||
object.localToWorld(vec);
|
||||
return vec;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user