title category import { OrbitControl } from "@oasis-engine/controls" ; import * as dat from "dat.gui" ; import { BlendShape , Camera , Logger , ModelMesh , SkinnedMeshRenderer , SystemInfo , UnlitMaterial , Vector3 , WebGLEngine } from "oasis-engine" ; Logger . enable ( ) ; const engine = new WebGLEngine ( "canvas" ) ; engine . canvas . width = window . innerWidth * SystemInfo . devicePixelRatio ; engine . canvas . height = window . innerHeight * SystemInfo . devicePixelRatio ; const scene = engine . sceneManager . activeScene ; const rootEntity = scene . createRootEntity ( ) ; const cameraEntity = rootEntity . createChild ( "cameraNode" ) ; cameraEntity . transform . position = new Vector3 ( 0 , 0 , 5 ) ; cameraEntity . addComponent ( Camera ) ; cameraEntity . addComponent ( OrbitControl ) ; const meshEntity = rootEntity . createChild ( "meshEntity" ) ; const skinnedMeshRenderer = meshEntity . addComponent ( SkinnedMeshRenderer ) ; const modelMesh = new ModelMesh ( engine ) ; const positions = [ new Vector3 ( - 1.0 , - 1.0 , 1.0 ) , new Vector3 ( 1.0 , - 1.0 , 1.0 ) , new Vector3 ( 1.0 , 1.0 , 1.0 ) , new Vector3 ( 1.0 , 1.0 , 1.0 ) , new Vector3 ( - 1.0 , 1.0 , 1.0 ) , new Vector3 ( - 1.0 , - 1.0 , 1.0 ) ] ; modelMesh . setPositions ( positions ) ; modelMesh . addSubMesh ( 0 , 6 ) ; const deltaPositions = [ new Vector3 ( 0.0 , 0.0 , 0.0 ) , new Vector3 ( 0.0 , 0.0 , 0.0 ) , new Vector3 ( - 1.0 , 0.0 , 0.0 ) , new Vector3 ( - 1.0 , 0.0 , 0.0 ) , new Vector3 ( 1.0 , 0.0 , 0.0 ) , new Vector3 ( 0.0 , 0.0 , 0.0 ) ] ; const blendShape = new BlendShape ( "BlendShapeA" ) ; blendShape . addFrame ( 1.0 , deltaPositions ) ; modelMesh . addBlendShape ( blendShape ) ; skinnedMeshRenderer . mesh = modelMesh ; skinnedMeshRenderer . setMaterial ( new UnlitMaterial ( engine ) ) ; modelMesh . uploadData ( false ) ; engine . run ( ) ; skinnedMeshRenderer . blendShapeWeights = new Float32Array ( [ 1.0 ] ) ; addDataGUI ( skinnedMeshRenderer ) ; /**
 * Add data GUI.
 */ function addDataGUI ( skinnedMeshRenderer ) { const gui = new dat . GUI ( ) ; const guiData = { blendShapeWeights : 1.0 } ; gui . add ( guiData , "blendShapeWeights" , 0 , 1 ) . onChange ( ( value ) => { skinnedMeshRenderer . blendShapeWeights [ 0 ] = value ; } ) ; }