title category import { BlinnPhongMaterial , Buffer , BufferBindFlag , BufferMesh , BufferUsage , Camera , Engine , IndexFormat , Mesh , MeshRenderer , PointLight , Vector3 , VertexElement , VertexElementFormat , WebGLEngine } from "oasis-engine" ; const engine = new WebGLEngine ( "canvas" ) ; engine . canvas . resizeByClientSize ( ) ; const rootEntity = engine . sceneManager . activeScene . createRootEntity ( "Root" ) ; const lightEntity = rootEntity . createChild ( "pointLight" ) ; const pointLight = lightEntity . addComponent ( PointLight ) ; pointLight . distance = 10 ; lightEntity . transform . setPosition ( 2 , 5 , 5 ) ; const cameraEntity = rootEntity . createChild ( "Camera" ) ; cameraEntity . transform . setPosition ( 0 , 6 , 10 ) ; cameraEntity . transform . lookAt ( new Vector3 ( 0 , 0 , 0 ) ) ; cameraEntity . addComponent ( Camera ) ; const cubeEntity = rootEntity . createChild ( "Cube" ) ; const cubeRenderer = cubeEntity . addComponent ( MeshRenderer ) ; const cubeGeometry = createCustomMesh ( engine , 1.0 ) ; const material = new BlinnPhongMaterial ( engine ) ; cubeEntity . transform . rotate ( 0 , 60 , 0 ) ; cubeRenderer . mesh = cubeGeometry ; cubeRenderer . setMaterial ( material ) ; engine . run ( ) ; param engine param size returns function createCustomMesh ( engine , size ) { const geometry = new BufferMesh ( engine , "CustomCubeGeometry" ) ; const vertices = new Float32Array ( [ - size , size , - size , 0 , 1 , 0 , size , size , - size , 0 , 1 , 0 , size , size , size , 0 , 1 , 0 , - size , size , size , 0 , 1 , 0 , - size , - size , - size , 0 , - 1 , 0 , size , - size , - size , 0 , - 1 , 0 , size , - size , size , 0 , - 1 , 0 , - size , - size , size , 0 , - 1 , 0 , - size , size , - size , - 1 , 0 , 0 , - size , size , size , - 1 , 0 , 0 , - size , - size , size , - 1 , 0 , 0 , - size , - size , - size , - 1 , 0 , 0 , size , size , - size , 1 , 0 , 0 , size , size , size , 1 , 0 , 0 , size , - size , size , 1 , 0 , 0 , size , - size , - size , 1 , 0 , 0 , - size , size , size , 0 , 0 , 1 , size , size , size , 0 , 0 , 1 , size , - size , size , 0 , 0 , 1 , - size , - size , size , 0 , 0 , 1 , - size , size , - size , 0 , 0 , - 1 , size , size , - size , 0 , 0 , - 1 , size , - size , - size , 0 , 0 , - 1 , - size , - size , - size , 0 , 0 , - 1 ] ) ; const indices = new Uint16Array ( [ 0 , 2 , 1 , 2 , 0 , 3 , 4 , 6 , 7 , 6 , 4 , 5 , 8 , 10 , 9 , 10 , 8 , 11 , 12 , 14 , 15 , 14 , 12 , 13 , 16 , 18 , 17 , 18 , 16 , 19 , 20 , 22 , 23 , 22 , 20 , 21 ] ) ; const vertexBuffer = new Buffer ( engine , BufferBindFlag . VertexBuffer , vertices , BufferUsage . Static ) ; const indexBuffer = new Buffer ( engine , BufferBindFlag . IndexBuffer , indices , BufferUsage . Static ) ; geometry . setVertexBufferBinding ( vertexBuffer , 24 ) ; geometry . setIndexBufferBinding ( indexBuffer , IndexFormat . UInt16 ) ; geometry . setVertexElements ( [ new VertexElement ( "POSITION" , 0 , VertexElementFormat . Vector3 , 0 ) , new VertexElement ( "NORMAL" , 12 , VertexElementFormat . Vector3 , 0 ) ] ) ; geometry . addSubMesh ( 0 , indices . length ) ; return geometry ; }