Skip to content

案例展示

创建 Group

<template>
  <div id="TO"></div>
</template>

<script setup>
import { onMounted } from 'vue';

onMounted(() => {
  const TO = new ThingOrigin(
    'groupTest',
    document.getElementById('TO')
  );

  const group = TO.model.initGroup();
  const cylinder = TO.model.initCylinder({
    position: {
      x: 10,
      y: 0,
      z: 0
    },
    material: {
      color: 0xff0000
    }
  });
  const cube = TO.model.initCube({
    position: {
      x: -20,
      y: 0,
      z: 0
    },
    material: {
      color: 0x0000ff
    }
  });
  group.add(cylinder, cube);
  group.position.set(0, 0, 0);
  TO.scene.add(group);
  TO.controls.initTransform();
  TO.controls.setTransformMode(group.name, 'translate');
});
</script>

<style scoped>
#TO {
  width: 100%;
  height: 400px;
  position: relative;
}
</style>

API 介绍

model.initGroup

方法签名返回值描述
initGroup(modelInfo?: modelInfoParams)Object3D创建 Group

参数说明:

参数名类型是否必选描述
modelInfomodelInfoParams模型参数