UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.

59 lines (47 loc) 2.31 kB
// import { SyncedTransform } from "../engine-components/SyncedTransform.js"; // import { DragControls } from "../engine-components/DragControls.js" // import { ObjectRaycaster } from "../engine-components/ui/Raycaster.js"; import { Object3D } from "three"; import type { Model, UIDProvider } from "./engine_types.js"; // import { Animation } from "../engine-components/Animation.js"; /** * @deprecated */ export function onDynamicObjectAdded(_obj: Object3D, _idProv: UIDProvider, _gltf?: Model) { // console.warn("Adding components on object has been temporarily disabled"); // // this ensures we have a drag component // let drag = getComponentInChildren(obj as GameObject, DragControls); // if (!drag) { // drag = GameObject.addNewComponent(obj as GameObject, DragControls, false); // drag.guid = idProv.generateUUID(); // } // // if a drag component is found we add a syncedTransform if none exists // if (drag && !GameObject.getComponent(drag.gameObject, SyncedTransform)) { // const st = GameObject.addNewComponent(drag.gameObject, SyncedTransform, false); // st.guid = idProv.generateUUID(); // // st.autoOwnership = true; // //drag.transformGroup = true; // //drag.targets = [obj]; // } // // if a drag component is found we add a syncedTransform if none exists // if (drag && !GameObject.getComponentInParent(drag.gameObject, ObjectRaycaster)) { // const st = GameObject.addNewComponent(drag.gameObject, ObjectRaycaster, false); // st.guid = idProv.generateUUID(); // } // if (gltf) { // if (gltf.animations?.length > 0) { // const firstAnimation = gltf.animations[0]; // const anim = GameObject.addNewComponent(obj, Animation, false); // anim.animations = [firstAnimation]; // } // } // let didDisablFrustumCulling = false; // obj.traverse(o => { // if (!o) return; // if (o["isSkinnedMesh"] === true) { // if (!didDisablFrustumCulling) console.log("Disabling frustum culling for skinned meshes", gltf); // didDisablFrustumCulling = true; // o.frustumCulled = false; // } // }); }