Babylonjs学习笔记

在drupal上搭建babylonjs

web.config
ASP.Net
babylon文件
<staticContent>
<mimeMap fileExtension = ".babylon" mimeType = "application/babylon" />
</staticContent>


BABYLON.SceneLoader.Load("filepath", "filename", engine, function(scene){})


添加mime
根目录下的.htaccess
根目录下的web.config

/etc/mime.types


Babylonjs基本功能:新建简单几何体和贴图

Shape


MeshBuilder Method
var shape = BABYLON.MeshBuilder.CreateShape(name, options, scene);


Box
var box = BABYLON.MeshBuilder.CreateBox("box", {}, scene);


Sphere
var sphere = BABYLON.MeshBuilder.CreateSphere("sphere", {}, scene);


Plane
var plane = BABYLON.MeshBuilder.CreatePlane("plane", {}, scene);


Ground
var Ground = BABYLON.MeshBuilder.CreateGround("ground", {}, scene);


faceUV and faceColors
Texture Atlas
faceUV[f] = (c * 1/6, r * 1/4, (c + 1) * 1/6, (r + 1) * 1/4);


var mat = new BABYLON.StandardMaterial("mat", scene);
var texture = new BABYLON.Texture("URL of Texture Atlas", scene);
mat.diffuseTexture = texture;


mesh.material = mat;


Colors
faceColors[f] = new BABYLON.Color4(r,g,b,a);


These colors are BJS Color4-class values. The Color4 alpha values become active if we set hasVertexAlpha = true :


Orientation
faceUV[1] = new BABYLON.Vector4(Ubottom_left, Vbottom_left, Utop_right, Vtop_right);


faceUV[1].x = Ubottom_left;
faceUV[1].y = Vbottom_left;
faceUV[1].z = Utop_right;
faceUV[1].w = Vtop_right;


var temp = faceUV[1].x;
  faceUV[f].x = faceUV[f].z;
  faceUV[f].z = temp;


Box - faceColors
var faceColors = new Array(6);


  faceColors[4] = new BABYLON.Color4(1,0,0,1);   // red top
  faceColors[1] = new BABYLON.Color4(0,1,0,1);


transparent color
box.hasVertexAlpha = true;


Position
pilot.position = new BABYLON.Vector3(2, 3, 4);
pilot.position.x  =  2;
pilot.position.y  =  3;
pilot.position.z  =  4;


Rotation
pilot.rotation.x  =  alpha; //rotation around x axis
pilot.rotation.y  =  beta; //rotation around y axis
pilot.rotation.z  =  gamma; //rotation around z axis


where alpha, beta and gamma are angles measured in radians.


mesh.addRotation(Math.PI/2, 0, 0).addRotation(0, Math.PI/2, 0).addRotation(0, 0, Math.PI/2);

在babylonjs里添加控制手柄
var VJC = new BABYLON.VirtualJoysticksCamera("VJC", scene.activeCamera.position, scene);
VJC.rotation = scene.activeCamera.rotation;
VJC.checkCollisions = scene.activeCamera.checkCollisions;
VJC.applyGravity = scene.activeCamera.applyGravity;
scene.activeCamera = VJC;
scene.activeCamera.attachControl(canvas);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值