- 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
廣告