lingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
75 lines • 2.92 kB
JavaScript
import math from "../math";
import loadJSON from "../display/utils/loaders/loadJSON";
import deserialize from "../api/serializer/deserialize";
import { getAppendablesById } from "../collections/idCollections";
import { ThirdPersonCamera, onBeforeRender } from "..";
import HandTracker from "../display/HandTracker";
import { mapRange } from "@lincode/math";
import { getWorldPlayComputed } from "../states/useWorldPlayComputed";
const data = await loadJSON("car/bentley2.json");
deserialize(data);
const [found] = getAppendablesById("car");
const model = found;
// const light = new PointLight()
// light.x = 0
// light.y = 50
// light.z = 0
// light.helper = false
// light.castShadow = true
const handTracker = new HandTracker();
handTracker.x = 150;
handTracker.y = 100;
model.onLoad = () => {
const handle = getWorldPlayComputed((play) => {
if (play) {
handle.cancel();
handTracker.track = true;
}
});
const cam = new ThirdPersonCamera();
cam.innerZ = 500;
cam.polarAngle = 100;
let gestureOld = "";
let gesture = "";
onBeforeRender(() => {
if (gestureOld !== handTracker.gesture &&
handTracker.gesture !== "None") {
gesture = handTracker.gesture;
if (gesture === "Closed_Fist") {
;
(async () => {
for (const part of getAppendablesById("exp")) {
const direction = math.normalize(part.getCenter());
direction.x = direction.x * math.randomRange(0.5, 1.5);
direction.y = direction.y * math.randomRange(1.5, 2);
direction.z = direction.z * math.randomRange(0.5, 1.5);
if (part.name === "Object_74") {
direction.x = 0;
direction.y = 0;
direction.z = -4;
}
else if (part.name === "Object_10")
direction.y = 2;
const { x, y, z } = math.multiply(direction, 50);
part.lerpTo(x, y, z);
await new Promise((resolve) => setTimeout(resolve, 10));
}
})();
}
else if (gesture === "Open_Palm") {
;
(async () => {
for (const part of getAppendablesById("exp")) {
part.lerpTo(0, 0, 0);
await new Promise((resolve) => setTimeout(resolve, 10));
}
})();
}
}
if (gesture === "Closed_Fist" || gesture === "Open_Palm") {
cam.gyrate(mapRange(handTracker.rotationY, -70, -80, -1, 1), 0);
}
gestureOld = handTracker.gesture;
});
};
//# sourceMappingURL=testExplode.js.map