UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

87 lines (86 loc) 3.18 kB
"use strict"; import { PHYSICS_RBD_COLLIDER_TYPES, PHYSICS_RBD_TYPES } from "./../../../core/physics/PhysicsAttribute"; import { BaseSopOperation } from "./_Base"; import { InputCloneMode } from "../../../engine/poly/InputCloneMode"; import { PhysicsRBDColliderType, PhysicsRBDType } from "../../../core/physics/PhysicsAttribute"; import { Vector3 } from "three"; export var SizeComputationMethod = /* @__PURE__ */ ((SizeComputationMethod2) => { SizeComputationMethod2["AUTO"] = "auto"; SizeComputationMethod2["MANUAL"] = "manual"; return SizeComputationMethod2; })(SizeComputationMethod || {}); export const SIZE_COMPUTATION_METHODS = [ "auto" /* AUTO */, "manual" /* MANUAL */ ]; export const SIZE_COMPUTATION_METHOD_MENU_ENTRIES = SIZE_COMPUTATION_METHODS.map((name, value) => ({ name, value })); export class PhysicsRBDAttributesSopOperation extends BaseSopOperation { static type() { return "physicsRBDAttributes"; } // override cook(inputCoreGroups: CoreGroup[], params: PhysicsRBDAttributesSopParams) { // const inputCoreGroup = inputCoreGroups[0]; // const objects = inputCoreGroup.objects(); // for (let object of objects) { // const colliderType = PHYSICS_RBD_COLLIDER_TYPES[params.colliderType]; // CorePhysicsAttribute.setRBDType(object, PHYSICS_RBD_TYPES[params.RBDType]); // CorePhysicsAttribute.setColliderType(object, colliderType); // CorePhysicsAttribute.setDensity(object, params.density); // CorePhysicsAttribute.setRestitution(object, params.restitution); // CorePhysicsAttribute.setLinearDamping(object, params.linearDamping); // CorePhysicsAttribute.setAngularDamping(object, params.angularDamping); // CorePhysicsAttribute.setCanSleep(object, params.canSleep); // if (isBooleanTrue(params.taddId)) { // CorePhysicsAttribute.setRBDId(object, params.id); // } // switch (colliderType) { // case PhysicsRBDColliderType.CUBOID: { // CorePhysicsAttribute.setCuboidSize(object, params.size); // break; // } // case PhysicsRBDColliderType.SPHERE: { // CorePhysicsAttribute.setRadius(object, params.radius); // break; // } // case PhysicsRBDColliderType.CAPSULE: { // CorePhysicsAttribute.setHeight(object, params.height); // CorePhysicsAttribute.setRadius(object, params.radius); // break; // } // } // } // return inputCoreGroup; // } } PhysicsRBDAttributesSopOperation.DEFAULT_PARAMS = { RBDType: PHYSICS_RBD_TYPES.indexOf(PhysicsRBDType.DYNAMIC), colliderType: PHYSICS_RBD_COLLIDER_TYPES.indexOf(PhysicsRBDColliderType.CUBOID), taddId: true, id: "", sizeMethod: SIZE_COMPUTATION_METHODS.indexOf("auto" /* AUTO */), borderRadius: 0.1, // cuboid sizes: new Vector3(1, 1, 1), size: 1, // sphere radius: 1, // capsule height: 0.5, // heightField rows: 20, cols: 20, // common density: 1, friction: 0.5, restitution: 0.5, linearDamping: 0, angularDamping: 0, linearVelocity: new Vector3(0, 0, 0), angularVelocity: new Vector3(0, 0, 0), gravityScale: 1, canSleep: true }; PhysicsRBDAttributesSopOperation.INPUT_CLONED_STATE = InputCloneMode.FROM_NODE;