UNPKG

lingo3d

Version:

Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor

127 lines 3.67 kB
import { Group, Mesh, MeshStandardMaterial } from "three"; import cookTrimeshGeometry from "../../engine/physx/cookTrimeshGeometry"; import { physxPtr } from "../../pointers/physxPtr"; import PhysicsObjectManager from "./PhysicsObjectManager"; import { boxGeometry } from "../primitives/Cube"; import { ssrExcludeSet } from "../../collections/ssrExcludeSet"; import { configLoadedSrcSystem } from "../../systems/configSystems/configLoadedSrcSystem"; const material = new MeshStandardMaterial({ visible: false }); export default class Loaded extends PhysicsObjectManager { $loadedGroup = new Group(); $loadedObject3d; constructor() { super(new Mesh(boxGeometry, material)); ssrExcludeSet.add(this.object3d); this.outerObject3d.add(this.$loadedGroup); } disposeNode() { super.disposeNode(); ssrExcludeSet.delete(this.object3d); } _src; get src() { return this._src; } set src(val) { this._src = val; val ? configLoadedSrcSystem.add(this) : configLoadedSrcSystem.delete(this); } _onLoad; get onLoad() { return this._onLoad; } set onLoad(cb) { this._onLoad = cb; this.cancelHandle("onLoad", cb && (() => this.$events.on("loaded", cb))); } widthSet; get width() { return super.width; } set width(val) { super.width = val; this.widthSet = true; } heightSet; get height() { return super.height; } set height(val) { super.height = val; this.heightSet = true; } depthSet; get depth() { return super.depth; } set depth(val) { super.depth = val; this.depthSet = true; } get innerRotationX() { return super.innerRotationX; } set innerRotationX(val) { super.innerRotationX = val; this.$loadedGroup.rotation.x = this.object3d.rotation.x; } get innerRotationY() { return super.innerRotationY; } set innerRotationY(val) { super.innerRotationY = val; this.$loadedGroup.rotation.y = this.object3d.rotation.y; } get innerRotationZ() { return super.innerRotationZ; } set innerRotationZ(val) { super.innerRotationZ = val; this.$loadedGroup.rotation.z = this.object3d.rotation.z; } get innerX() { return super.innerX; } set innerX(val) { super.innerX = val; this.$loadedGroup.position.x = this.object3d.position.x; } get innerY() { return super.innerY; } set innerY(val) { super.innerY = val; this.$loadedGroup.position.y = this.object3d.position.y; } get innerZ() { return super.innerZ; } set innerZ(val) { super.innerZ = val; this.$loadedGroup.position.z = this.object3d.position.z; } get innerVisible() { return this.$loadedGroup.visible; } set innerVisible(val) { this.$loadedGroup.visible = val; } get boxVisible() { return false; } set boxVisible(val) { //todo: implement appending box to object3d } $getPxShape(mode, actor) { if (mode === "map") { const { material, shapeFlags, PxRigidActorExt, pxFilterData } = physxPtr[0]; const shape = PxRigidActorExt.prototype.createExclusiveShape(actor, cookTrimeshGeometry(this._src, this), material, shapeFlags); shape.setSimulationFilterData(pxFilterData); return shape; } return super.$getPxShape(mode, actor); } } //# sourceMappingURL=Loaded.js.map