本文整理汇总了TypeScript中THREE.Mesh.updateMatrix方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Mesh.updateMatrix方法的具体用法?TypeScript Mesh.updateMatrix怎么用?TypeScript Mesh.updateMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Mesh
的用法示例。
在下文中一共展示了Mesh.updateMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _setupLevel
private _setupLevel () {
//todo: load from levelfile
var cubeGeo = new THREE.CubeGeometry(10, 10, 10);
var geo = new THREE.Geometry();
var mesh = new THREE.Mesh(cubeGeo);
var wall = this.getPhysics().world.CreateBody(this.getPhysics().defaultWallDefinition);
wall.SetUserData({type: 'wall'});
var isBoxToCreate = false;
for (var x = 0; x < 100; x++ ) {
for (var y = 0; y < 100; y++) {
if (x== 0 || x == 99 || y == 0 || y == 99) {
isBoxToCreate = true;
} else {
isBoxToCreate = Math.random() * 10 < 1;
}
if ((x > 45 && x < 55 ) && (y > 45 && y < 55)) {
isBoxToCreate = false;
}
if (isBoxToCreate) {
var posx = (x - 50) * 10;
var posy = (y - 50) * 10;
mesh.position.x = posx;
mesh.position.y = posy;
THREE.GeometryUtils.merge(geo, mesh);
this.getPhysics().defaultWallFixture.shape.SetAsOrientedBox(5 / this._physScale, 5 / this._physScale, new Box2D.b2Vec2(posx / this._physScale, posy / this._physScale), 0);
wall.CreateFixture(this.getPhysics().defaultWallFixture);
}
}
}
var group = new THREE.Mesh(geo, new THREE.MeshLambertMaterial({color: 0xffff00}));
group.matrixAutoUpdate = false;
group.updateMatrix();
this.getScene().add(group);
}
示例2: initClouds
function initClouds() {
container = document.getElementById('cd-main-overlay')!;
// Bg gradient
const canvas = document.createElement('canvas');
canvas.width = 32;
canvas.height = window.innerHeight;
const context = canvas.getContext('2d')!;
const gradient = context.createLinearGradient(0, 0, 0, canvas.height);
gradient.addColorStop(0, '#1e4877');
gradient.addColorStop(0.5, '#4584b4');
context.fillStyle = gradient;
context.fillRect(0, 0, canvas.width, canvas.height);
container.style.background = `url("${canvas.toDataURL('image/png')}")`;
//
camera = new PerspectiveCamera(30, window.innerWidth / window.innerHeight, 1, 3000);
camera.position.z = 3000;
scene = new Scene();
geometry = new Geometry();
const texture = new TextureLoader().load('/images/cloud10.png', animateClouds);
const fog = new Fog(0x4584b4, -100, 3000);
const vs = document.getElementById('vs');
const fs = document.getElementById('fs');
const vertexShader = vs!.textContent!;
const fragmentShader = fs!.textContent!;
material = new ShaderMaterial({
depthTest: false,
depthWrite: false,
fragmentShader,
transparent: true,
uniforms: {
fogColor: {
type: 'c',
value: fog.color,
},
fogFar: {
type: 'f',
value: fog.far,
},
fogNear: {
type: 'f',
value: fog.near,
},
map: {
type: 't',
value: texture,
},
},
vertexShader,
});
const plane = new Mesh(new PlaneGeometry(64, 64));
for (let i = 0; i < 8000; i++) {
plane.position.x = Math.random() * 1000 - 500;
plane.position.y = -Math.random() * Math.random() * 200 - 15;
plane.position.z = i;
plane.rotation.z = Math.random() * Math.PI;
plane.scale.x = plane.scale.y = Math.random() * Math.random() * 1.5 + 0.5;
plane.updateMatrix();
geometry.merge(plane.geometry as Geometry, plane.matrix);
}
mesh = new Mesh(geometry, material);
scene.add(mesh);
mesh = new Mesh(geometry, material);
mesh.position.z = -8000;
scene.add(mesh);
renderer = new WebGLRenderer({
alpha: true,
antialias: false,
});
renderer.setSize(window.innerWidth, window.innerHeight);
container.append(renderer.domElement);
document.addEventListener('mousemove', onDocumentMouseMoveClouds, false);
window.addEventListener('resize', onWindowResizeClouds, false);
}