|
|
|
@ -1,11 +1,11 @@
|
|
|
|
|
import * as THREE from 'three';
|
|
|
|
|
import { Clock, CubeTextureLoader, HemisphereLight, Mesh, MeshStandardMaterial, PlaneGeometry, PointLight, RepeatWrapping, RGBFormat, SphereGeometry, TextureLoader } from 'three';
|
|
|
|
|
import { begin } from 'xaop';
|
|
|
|
|
import { app } from '../ApplicationServices/Application';
|
|
|
|
|
import { Command } from '../Editor/CommandMachine';
|
|
|
|
|
|
|
|
|
|
export class DrawFloor implements Command
|
|
|
|
|
{
|
|
|
|
|
textureLoader: THREE.TextureLoader;
|
|
|
|
|
textureLoader: TextureLoader;
|
|
|
|
|
|
|
|
|
|
get scene()
|
|
|
|
|
{
|
|
|
|
@ -13,7 +13,7 @@ export class DrawFloor implements Command
|
|
|
|
|
}
|
|
|
|
|
constructor()
|
|
|
|
|
{
|
|
|
|
|
this.textureLoader = new THREE.TextureLoader();
|
|
|
|
|
this.textureLoader = new TextureLoader();
|
|
|
|
|
}
|
|
|
|
|
async exec()
|
|
|
|
|
{
|
|
|
|
@ -44,7 +44,7 @@ export class DrawFloor implements Command
|
|
|
|
|
|
|
|
|
|
private drawFloor()
|
|
|
|
|
{
|
|
|
|
|
let floorMat = new THREE.MeshStandardMaterial({
|
|
|
|
|
let floorMat = new MeshStandardMaterial({
|
|
|
|
|
roughness: 0.8,
|
|
|
|
|
color: 0xffffff,
|
|
|
|
|
metalness: 0.2,
|
|
|
|
@ -54,8 +54,8 @@ export class DrawFloor implements Command
|
|
|
|
|
});
|
|
|
|
|
this.materialList.push(floorMat);
|
|
|
|
|
|
|
|
|
|
var floorGeometry = new THREE.PlaneGeometry(20, 20);
|
|
|
|
|
var floorMesh = new THREE.Mesh(floorGeometry, floorMat);
|
|
|
|
|
var floorGeometry = new PlaneGeometry(20, 20);
|
|
|
|
|
var floorMesh = new Mesh(floorGeometry, floorMat);
|
|
|
|
|
floorMesh.receiveShadow = true;
|
|
|
|
|
this.scene.add(floorMesh);
|
|
|
|
|
|
|
|
|
@ -66,7 +66,7 @@ export class DrawFloor implements Command
|
|
|
|
|
floorMat.transparent = true;
|
|
|
|
|
floorMat.opacity = 0.9;
|
|
|
|
|
|
|
|
|
|
// let ref = new THREE.Reflector(20, 20, {
|
|
|
|
|
// let ref = new Reflector(20, 20, {
|
|
|
|
|
// clipBias: 0.003,
|
|
|
|
|
// textureWidth: app.m_Viewer.Width * window.devicePixelRatio,
|
|
|
|
|
// textureHeight: app.m_Viewer.Height * window.devicePixelRatio,
|
|
|
|
@ -84,8 +84,8 @@ export class DrawFloor implements Command
|
|
|
|
|
|
|
|
|
|
this.textureLoader.load("textures/hardwood2_diffuse.jpg", function (map)
|
|
|
|
|
{
|
|
|
|
|
map.wrapS = THREE.RepeatWrapping;
|
|
|
|
|
map.wrapT = THREE.RepeatWrapping;
|
|
|
|
|
map.wrapS = RepeatWrapping;
|
|
|
|
|
map.wrapT = RepeatWrapping;
|
|
|
|
|
map.anisotropy = 16;
|
|
|
|
|
map.repeat.set(10, 24);
|
|
|
|
|
|
|
|
|
@ -97,27 +97,27 @@ export class DrawFloor implements Command
|
|
|
|
|
});
|
|
|
|
|
this.textureLoader.load("textures/hardwood2_bump.jpg", function (map)
|
|
|
|
|
{
|
|
|
|
|
map.wrapS = THREE.RepeatWrapping;
|
|
|
|
|
map.wrapT = THREE.RepeatWrapping;
|
|
|
|
|
map.wrapS = RepeatWrapping;
|
|
|
|
|
map.wrapT = RepeatWrapping;
|
|
|
|
|
map.anisotropy = 16;
|
|
|
|
|
map.repeat.set(10, 24);
|
|
|
|
|
|
|
|
|
|
self.materialList.forEach(m =>
|
|
|
|
|
{
|
|
|
|
|
(<THREE.MeshStandardMaterial>m).bumpMap = map;
|
|
|
|
|
(<MeshStandardMaterial>m).bumpMap = map;
|
|
|
|
|
m.needsUpdate = true;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
this.textureLoader.load("textures/hardwood2_roughness.jpg", function (map)
|
|
|
|
|
{
|
|
|
|
|
map.wrapS = THREE.RepeatWrapping;
|
|
|
|
|
map.wrapT = THREE.RepeatWrapping;
|
|
|
|
|
map.wrapS = RepeatWrapping;
|
|
|
|
|
map.wrapT = RepeatWrapping;
|
|
|
|
|
map.anisotropy = 16;
|
|
|
|
|
map.repeat.set(10, 24);
|
|
|
|
|
|
|
|
|
|
self.materialList.forEach(m =>
|
|
|
|
|
{
|
|
|
|
|
(<THREE.MeshStandardMaterial>m).roughnessMap = map;
|
|
|
|
|
(<MeshStandardMaterial>m).roughnessMap = map;
|
|
|
|
|
m.needsUpdate = true;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -125,18 +125,18 @@ export class DrawFloor implements Command
|
|
|
|
|
|
|
|
|
|
drawLight()
|
|
|
|
|
{
|
|
|
|
|
var bulbGeometry = new THREE.SphereGeometry(0.02, 16, 8);
|
|
|
|
|
// let bulbLight = new THREE.PointLight(0xffee88, 1.5, 100, 1);
|
|
|
|
|
let bulbLight = new THREE.PointLight(0x999999, 1.5, 100, 2);
|
|
|
|
|
var bulbGeometry = new SphereGeometry(0.02, 16, 8);
|
|
|
|
|
// let bulbLight = new PointLight(0xffee88, 1.5, 100, 1);
|
|
|
|
|
let bulbLight = new PointLight(0x999999, 1.5, 100, 2);
|
|
|
|
|
|
|
|
|
|
let bulbMat = new THREE.MeshStandardMaterial({
|
|
|
|
|
let bulbMat = new MeshStandardMaterial({
|
|
|
|
|
emissive: 0xffffee,
|
|
|
|
|
emissiveIntensity: 1,
|
|
|
|
|
color: 0x000000
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bulbLight.add(new THREE.Mesh(bulbGeometry, bulbMat));
|
|
|
|
|
bulbLight.add(new Mesh(bulbGeometry, bulbMat));
|
|
|
|
|
bulbLight.position.set(0, 2, 2);
|
|
|
|
|
bulbLight.castShadow = true;
|
|
|
|
|
|
|
|
|
@ -150,7 +150,7 @@ export class DrawFloor implements Command
|
|
|
|
|
this.scene.add(light2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var clock = new THREE.Clock();
|
|
|
|
|
var clock = new Clock();
|
|
|
|
|
begin(app.Viewer, app.Viewer.StartRender, () =>
|
|
|
|
|
{
|
|
|
|
|
var time = Date.now() * 0.0005;
|
|
|
|
@ -162,8 +162,8 @@ export class DrawFloor implements Command
|
|
|
|
|
private drawHemiLight()
|
|
|
|
|
{
|
|
|
|
|
//0xddeeff 0x0f0e0d
|
|
|
|
|
// var hemiLight = new THREE.HemisphereLight(0xffffff, 0xffffff, 0.05);
|
|
|
|
|
var hemiLight = new THREE.HemisphereLight(0xddeeff, 0x0f0e0d, 0.05);
|
|
|
|
|
// var hemiLight = new HemisphereLight(0xffffff, 0xffffff, 0.05);
|
|
|
|
|
var hemiLight = new HemisphereLight(0xddeeff, 0x0f0e0d, 0.05);
|
|
|
|
|
hemiLight.intensity = 23;
|
|
|
|
|
this.scene.add(hemiLight);
|
|
|
|
|
}
|
|
|
|
@ -171,7 +171,7 @@ export class DrawFloor implements Command
|
|
|
|
|
|
|
|
|
|
drawWall()
|
|
|
|
|
{
|
|
|
|
|
// let floorMat = new THREE.MeshStandardMaterial({
|
|
|
|
|
// let floorMat = new MeshStandardMaterial({
|
|
|
|
|
// roughness: 0.8,
|
|
|
|
|
// color: 0xffffff,
|
|
|
|
|
// metalness: 0.2,
|
|
|
|
@ -180,8 +180,8 @@ export class DrawFloor implements Command
|
|
|
|
|
|
|
|
|
|
// this.textureLoader.load("textures/wallmap.png", function (map)
|
|
|
|
|
// {
|
|
|
|
|
// map.wrapS = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapT = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapS = RepeatWrapping;
|
|
|
|
|
// map.wrapT = RepeatWrapping;
|
|
|
|
|
// map.anisotropy = 4;
|
|
|
|
|
// map.repeat.set(10, 24);
|
|
|
|
|
// floorMat.map = map;
|
|
|
|
@ -190,7 +190,7 @@ export class DrawFloor implements Command
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let wallFont = new Solid3d(4, 0.12, 2.8);
|
|
|
|
|
// let obj = wallFont.Draw(RenderType.Wireframe) as THREE.Mesh;
|
|
|
|
|
// let obj = wallFont.Draw(RenderType.Wireframe) as Mesh;
|
|
|
|
|
// obj.material = floorMat;
|
|
|
|
|
|
|
|
|
|
// obj.castShadow = true;
|
|
|
|
@ -200,18 +200,18 @@ export class DrawFloor implements Command
|
|
|
|
|
// let objRight = obj.clone();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// obj.applyMatrix(Move(new THREE.Vector3(-2.1, 4, 0)));
|
|
|
|
|
// obj.applyMatrix(Move(new Vector3(-2.1, 4, 0)));
|
|
|
|
|
|
|
|
|
|
// let roMatLeft = new THREE.Matrix4();
|
|
|
|
|
// let roMatLeft = new Matrix4();
|
|
|
|
|
// roMatLeft.makeRotationZ(Math.PI / 2);
|
|
|
|
|
// objLeft.applyMatrix(roMatLeft);
|
|
|
|
|
|
|
|
|
|
// let roMatRight = new THREE.Matrix4();
|
|
|
|
|
// let roMatRight = new Matrix4();
|
|
|
|
|
// roMatRight.makeRotationZ(Math.PI / 2);
|
|
|
|
|
// objRight.applyMatrix(roMatRight);
|
|
|
|
|
|
|
|
|
|
// objLeft.applyMatrix(Move(new THREE.Vector3(-2, 0, 0)))
|
|
|
|
|
// objRight.applyMatrix(Move(new THREE.Vector3(2, 0, 0)))
|
|
|
|
|
// objLeft.applyMatrix(Move(new Vector3(-2, 0, 0)))
|
|
|
|
|
// objRight.applyMatrix(Move(new Vector3(2, 0, 0)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this.scene.add(obj);
|
|
|
|
@ -219,7 +219,7 @@ export class DrawFloor implements Command
|
|
|
|
|
// this.scene.add(objRight);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let skyMaterail = new THREE.MeshStandardMaterial({
|
|
|
|
|
// let skyMaterail = new MeshStandardMaterial({
|
|
|
|
|
// roughness: 0.8,
|
|
|
|
|
// color: 0xffffff,
|
|
|
|
|
// metalness: 0.2,
|
|
|
|
@ -227,10 +227,10 @@ export class DrawFloor implements Command
|
|
|
|
|
// })
|
|
|
|
|
// //天花板.
|
|
|
|
|
// let skyWall = new Solid3d(4.12, 4, 0.12);
|
|
|
|
|
// let skyObj = skyWall.Draw(RenderType.Wireframe) as THREE.Mesh;
|
|
|
|
|
// let skyObj = skyWall.Draw(RenderType.Wireframe) as Mesh;
|
|
|
|
|
// skyObj.material = skyMaterail;
|
|
|
|
|
|
|
|
|
|
// skyObj.applyMatrix(Move(new THREE.Vector3(-2.12, 0, 2.8)));
|
|
|
|
|
// skyObj.applyMatrix(Move(new Vector3(-2.12, 0, 2.8)));
|
|
|
|
|
|
|
|
|
|
// this.scene.add(skyObj);
|
|
|
|
|
}
|
|
|
|
@ -243,7 +243,7 @@ export class DrawFloor implements Command
|
|
|
|
|
|
|
|
|
|
// obj.castShadow = true;
|
|
|
|
|
|
|
|
|
|
// let mat = new THREE.MeshStandardMaterial({
|
|
|
|
|
// let mat = new MeshStandardMaterial({
|
|
|
|
|
// roughness: 0.8,
|
|
|
|
|
// color: 0xffffff,
|
|
|
|
|
// metalness: 0.2,
|
|
|
|
@ -252,14 +252,14 @@ export class DrawFloor implements Command
|
|
|
|
|
|
|
|
|
|
// this.textureLoader.load("textures/door.png", function (map)
|
|
|
|
|
// {
|
|
|
|
|
// map.wrapS = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapT = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapS = RepeatWrapping;
|
|
|
|
|
// map.wrapT = RepeatWrapping;
|
|
|
|
|
// map.anisotropy = 16;
|
|
|
|
|
// map.repeat.set(1, 1);
|
|
|
|
|
// mat.map = map;
|
|
|
|
|
// mat.needsUpdate = true;
|
|
|
|
|
// });
|
|
|
|
|
// (<THREE.Mesh>obj).material = mat;
|
|
|
|
|
// (<Mesh>obj).material = mat;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this.scene.add(obj);
|
|
|
|
@ -275,8 +275,8 @@ export class DrawFloor implements Command
|
|
|
|
|
path + 'posy' + format, path + 'negy' + format,
|
|
|
|
|
path + 'posz' + format, path + 'negz' + format
|
|
|
|
|
];
|
|
|
|
|
var textureCube = new THREE.CubeTextureLoader().load(urls);
|
|
|
|
|
textureCube.format = THREE.RGBFormat;
|
|
|
|
|
var textureCube = new CubeTextureLoader().load(urls);
|
|
|
|
|
textureCube.format = RGBFormat;
|
|
|
|
|
return textureCube;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -286,17 +286,17 @@ export class DrawFloor implements Command
|
|
|
|
|
|
|
|
|
|
// let obj = solid.Draw(RenderType.Wireframe);
|
|
|
|
|
|
|
|
|
|
// // obj = new THREE.Mesh(new THREE.SphereGeometry(1, 32, 32));
|
|
|
|
|
// // obj = new Mesh(new SphereGeometry(1, 32, 32));
|
|
|
|
|
// obj.position.set(0, 0, 1);
|
|
|
|
|
|
|
|
|
|
// obj.castShadow = true;
|
|
|
|
|
|
|
|
|
|
// let cubeCamera1 = new THREE.CubeCamera(0.1, 15, 1024);
|
|
|
|
|
// let cubeCamera2 = new THREE.CubeCamera(0.1, 15, 1024);
|
|
|
|
|
// let cubeCamera1 = new CubeCamera(0.1, 15, 1024);
|
|
|
|
|
// let cubeCamera2 = new CubeCamera(0.1, 15, 1024);
|
|
|
|
|
// cubeCamera1.position.set(0, 0, 1);
|
|
|
|
|
// cubeCamera2.position.set(0, 0, 1);
|
|
|
|
|
// cubeCamera1.renderTarget.texture.minFilter = THREE.LinearMipMapLinearFilter;
|
|
|
|
|
// cubeCamera2.renderTarget.texture.minFilter = THREE.LinearMipMapLinearFilter;
|
|
|
|
|
// cubeCamera1.renderTarget.texture.minFilter = LinearMipMapLinearFilter;
|
|
|
|
|
// cubeCamera2.renderTarget.texture.minFilter = LinearMipMapLinearFilter;
|
|
|
|
|
// cubeCamera1.renderTarget.texture.anisotropy = 16;
|
|
|
|
|
// cubeCamera2.renderTarget.texture.anisotropy = 16;
|
|
|
|
|
|
|
|
|
@ -307,7 +307,7 @@ export class DrawFloor implements Command
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let mat = new THREE.MeshStandardMaterial({
|
|
|
|
|
// let mat = new MeshStandardMaterial({
|
|
|
|
|
// roughness: 0.8,
|
|
|
|
|
// metalness: 0.8,
|
|
|
|
|
// // color: 0xffffff,
|
|
|
|
@ -319,8 +319,8 @@ export class DrawFloor implements Command
|
|
|
|
|
|
|
|
|
|
// this.textureLoader.load("textures/Metal/130616_header2.jpg", function (map)
|
|
|
|
|
// {
|
|
|
|
|
// map.wrapS = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapT = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapS = RepeatWrapping;
|
|
|
|
|
// map.wrapT = RepeatWrapping;
|
|
|
|
|
// map.anisotropy = 16;
|
|
|
|
|
// map.repeat.set(1, 1);
|
|
|
|
|
// mat.map = map;
|
|
|
|
@ -329,8 +329,8 @@ export class DrawFloor implements Command
|
|
|
|
|
|
|
|
|
|
// this.textureLoader.load("textures/Metal/Titanium-Scuffed_basecolor.png", function (map)
|
|
|
|
|
// {
|
|
|
|
|
// map.wrapS = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapT = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapS = RepeatWrapping;
|
|
|
|
|
// map.wrapT = RepeatWrapping;
|
|
|
|
|
// map.anisotropy = 16;
|
|
|
|
|
// map.repeat.set(1, 1);
|
|
|
|
|
// mat.map = map;
|
|
|
|
@ -338,8 +338,8 @@ export class DrawFloor implements Command
|
|
|
|
|
// });
|
|
|
|
|
// this.textureLoader.load("textures/Metal/Titanium-Scuffed_roughness.png", function (map)
|
|
|
|
|
// {
|
|
|
|
|
// map.wrapS = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapT = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapS = RepeatWrapping;
|
|
|
|
|
// map.wrapT = RepeatWrapping;
|
|
|
|
|
// map.anisotropy = 16;
|
|
|
|
|
// map.repeat.set(1, 1);
|
|
|
|
|
// mat.roughnessMap = map;
|
|
|
|
@ -347,8 +347,8 @@ export class DrawFloor implements Command
|
|
|
|
|
// });
|
|
|
|
|
// this.textureLoader.load("textures/Metal/Titanium-Scuffed_normal.png", function (map)
|
|
|
|
|
// {
|
|
|
|
|
// map.wrapS = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapT = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapS = RepeatWrapping;
|
|
|
|
|
// map.wrapT = RepeatWrapping;
|
|
|
|
|
// map.anisotropy = 16;
|
|
|
|
|
// map.repeat.set(1, 1);
|
|
|
|
|
// mat.normalMap = map;
|
|
|
|
@ -356,8 +356,8 @@ export class DrawFloor implements Command
|
|
|
|
|
// });
|
|
|
|
|
// this.textureLoader.load("textures/Metal/Titanium-Scuffed_metallic.png", function (map)
|
|
|
|
|
// {
|
|
|
|
|
// map.wrapS = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapT = THREE.RepeatWrapping;
|
|
|
|
|
// map.wrapS = RepeatWrapping;
|
|
|
|
|
// map.wrapT = RepeatWrapping;
|
|
|
|
|
// map.anisotropy = 16;
|
|
|
|
|
// map.repeat.set(1, 1);
|
|
|
|
|
// mat.metalnessMap = map;
|
|
|
|
@ -388,7 +388,7 @@ export class DrawFloor implements Command
|
|
|
|
|
// // obj.visible = true;
|
|
|
|
|
// // isOne = !isOne;
|
|
|
|
|
// // });
|
|
|
|
|
// (<THREE.Mesh>obj).material = mat;
|
|
|
|
|
// (<Mesh>obj).material = mat;
|
|
|
|
|
// this.scene.add(obj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|