- BabylonJS 教程
- BabylonJS - 主页
- BabylonJS - 导言
- BabylonJS - 环境设置
- BabylonJS - 概述
- BabylonJS - 基本元素
- BabylonJS - 材质
- BabylonJS - 动画
- BabylonJS - 摄像机
- BabylonJS - 灯光
- BabylonJS - 参数形状
- BabylonJS - 网格
- VectorPosition 和 Rotation
- BabylonJS - 贴花
- BabylonJS - Curve3
- BabylonJS - 动态纹理
- BabylonJS - 视差贴图
- BabylonJS - 镜头光晕
- BabylonJS - 创建屏幕截图
- BabylonJS - 反射探针
- 标准渲染管道
- BabylonJS - ShaderMaterial
- BabylonJS - 骨骼和骨架
- BabylonJS - 物理引擎
- BabylonJS - 播放声音和音乐
- BabylonJS 实用资源
- BabylonJS - 快速指南
- BabylonJS - 实用资源
- BabylonJS - 讨论
BabylonJS - 比例
缩放基本上意味着以统一的比例增加或减少对象的大小。我们现在考虑一个例子,在这个例子中,我们将在 x 或 y 或 z 轴上增加/减少对象的大小。
示例
<!doctype html> <html> <head> <meta charset = "utf-8"> <title>BabylonJs - Basic Element-Creating Scene</title> <script src = "babylon.js"></script> <style> canvas {width: 100%; height: 100%;} </style> </head> <body> <canvas id = "renderCanvas"></canvas> <script type="text/javascript"> var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var createScene = function() { var scene = new BABYLON.Scene(engine); scene.clearColor = new BABYLON.Color3(0, 1, 0); var camera = new BABYLON.ArcRotateCamera("Camera", 1, 0.8, 10, new BABYLON.Vector3(0, 0, 0), scene); scene.activeCamera.attachControl(canvas); var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(0, 100, 100), scene); var boxa = BABYLON.Mesh.CreateBox("BoxA", 1.0, scene); boxa.position = new BABYLON.Vector3(0,0.5,0); var boxb = BABYLON.Mesh.CreateBox("BoxB", 1.0, scene); boxb.position = new BABYLON.Vector3(3,0.5,0); boxb.scaling = new BABYLON.Vector3(2,1,2); var boxc = BABYLON.Mesh.CreateBox("BoxC", 1.0, scene); boxc.position = new BABYLON.Vector3(-3,0.5,0); boxc.scaling = new BABYLON.Vector3(2,1,2); var boxd = BABYLON.Mesh.CreateBox("BoxD", 1.0, scene); boxd.position = new BABYLON.Vector3(0,0.5,3); boxd.scaling = new BABYLON.Vector3(2,1,2); var boxe = BABYLON.Mesh.CreateBox("BoxE", 1.0, scene); boxe.position = new BABYLON.Vector3(0,0.5,-3); boxe.scaling = new BABYLON.Vector3(2,1,2); var ground = BABYLON.Mesh.CreateGround("ground1", 10, 6, 2, scene); ground.position = new BABYLON.Vector3(0,0,0); return scene; }; var scene = createScene(); engine.runRenderLoop(function() { scene.render(); }); </script> </body> </html>
演示
说明
我们以 2、1、2 的值按 x、y 和 z 方向进行了缩放,并使用 new BABYLON.Vector3(2,1,2) 进行缩放。
babylonjs_basic_elements.htm
广告