跳到内容
SCRM DOC

1.3 Classes

创建目标对象

// 实例
const xrFrameSystem = wx.getXrFrameSystem();

// 通过场景创建这个你需要的实例对象
const cameraElement = scene.createElement(xrFrameSystem.XRCamera);

// 获取节点内的组件, 设置变换的位置;
cameraElement.getComponent(xrFrameSystem.Transform).position.setValue(0, 0, 6);

获取已有目标对象

// 获取目标对象
const Elementdogdltf = scene.getElementById('dogdltf');
// 获取目标对象中的组件
Elementdogdltf.getComponent(xrFrameSystem.Transform)

1.3.1 Transform 变换

const gltfElement = scene.createElement(xrFrameSystem.XRGLTF);
gltfElement.getComponent(xrFrameSystem.Transform).position.setValue(2,3,2)

1.3.2 xr-light 光照

type: 光类型 intensity : 亮度

1.3.2 Camera 照相机


// 创建一个照相机
const cameraElement = scene.createElement(xrFrameSystem.XRCamera);

// 挂载到shadowRoot节点下
this.shadowRoot.addChild(cameraElement);

// 设置照相机位置
cameraElement.getComponent(xrFrameSystem.Transform).position.setValue(0, 0, 9);

// 获取节点上的 Camera 组件, 并且设置组件属性
cameraElement.getComponent(xrFrameSystem.Camera).setData({
	target: gltfElement.getComponent(xrFrameSystem.Transform),// 目标对象
	background: 'skybox'
  });

cameraElement.addComponent(xrFrameSystem.CameraOrbitControl, {});

1.3.3 CameraOrbitControl 相机控制器组件

  • 控制相机可以围绕目标点(通常是模型或场景中心)进行轨道式旋转、缩放和平移
cameraElement.addComponent(xrFrameSystem.CameraOrbitControl, {
	isLockY:true,
	isLockMove:true,
});

1.3.4 Animation 动画

  • 开启动画
this.animator.play('动作名称',{
    loop:1
})
  • 暂停动画
this.animator.stop()
  • 监听某个片段播放停止时
<xr-gltf  bind:anim-stop="handleAnimationStop"></xr-gltf>


plaintext
model: {
  samplers: Array(0),        // 纹理采样器数组(此处为空)
  textures: Array(0),        // 纹理数组(此处为空)
  materials: Array(3),       // 材质数组(包含3个材质)
  meshes: Array(3),          // 网格数组(包含3个网格)
  nodes: Array(9),           // 节点树(包含9个节点,用于构建场景层次结构)
  ...
}

_scene: t {                 // 场景对象
  _type: "scene",           // 对象类型为场景
  defaultComponents: {...}, // 默认组件配置
  dataMapping: {...},       // 数据映射关系
  neverTick: false,         // 是否不进行逐帧更新
  _inXML: true,             // 是否以XML格式存储
  ...
}

切换 网格数据(ME)



### 工具

// 模型查看 https://gltf.nsdt.cloud/ https://gltf-viewer.donmccurdy.com/ https://www.euyu.com/editor.html https://gltf.dev.widiazine.com/editor.html?url=https://cdn.widiazine.com/scrm/doge_ldle_test_20250717_31752731545254.glb

#### 有配件(眼镜、耳饰等)在3D软件里都已经对齐好原点和缩放,并且都“戴”在正确位置导出

切换 visible 属性,

光照

KHR_materials_unlit 文件 https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_unlit/README.md

反向链接 · 1

本页目录