@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
50 lines (45 loc) • 1.72 kB
text/typescript
/**
* Converts InstancedMesh to Mesh
*
*
*
*/
import {InstancedMesh} from 'three';
import {TypedSopNode} from './_Base';
import {CoreGroup} from '../../../core/geometry/Group';
import {InstancedMeshToMeshSopOperation} from '../../operations/sop/InstancedMeshToMesh';
import {NodeParamsConfig, ParamConfig} from '../utils/params/ParamsConfig';
import {SopType} from '../../poly/registers/nodes/types/Sop';
import {registerObjectType, ObjectType} from '../../../core/geometry/Constant';
const DEFAULT = InstancedMeshToMeshSopOperation.DEFAULT_PARAMS;
class InstancedMeshToMeshSopParamsConfig extends NodeParamsConfig {
cloneGeometry = ParamConfig.BOOLEAN(DEFAULT.cloneGeometry);
}
const ParamsConfig = new InstancedMeshToMeshSopParamsConfig();
export class InstancedMeshToMeshSopNode extends TypedSopNode<InstancedMeshToMeshSopParamsConfig> {
override paramsConfig = ParamsConfig;
static override type() {
return SopType.INSTANCED_MESH_TO_MESH;
}
override initializeNode() {
super.initializeNode();
this.io.inputs.setCount(1);
this.io.inputs.initInputsClonedState(InstancedMeshToMeshSopOperation.INPUT_CLONED_STATE);
registerObjectType({
type: ObjectType.INSTANCED_MESH,
checkFunc: (o) => {
if ((o as InstancedMesh).isInstancedMesh) {
return ObjectType.INSTANCED_MESH;
}
},
ctor: InstancedMesh,
humanName: 'InstancedMesh',
});
}
private _operation: InstancedMeshToMeshSopOperation | undefined;
override async cook(inputCoreGroups: CoreGroup[]) {
this._operation = this._operation || new InstancedMeshToMeshSopOperation(this.scene(), this.states, this);
const coreGroup = await this._operation.cook(inputCoreGroups, this.pv);
this.setCoreGroup(coreGroup);
}
}