升级到webpack4

This commit is contained in:
ChenX
2018-08-17 17:39:11 +08:00
parent 563ea73750
commit c99f7f8149
11 changed files with 1935 additions and 5684 deletions

View File

@@ -4,14 +4,6 @@ import { KeyBoard, MouseKey } from './KeyEnum';
import { Vector3 } from 'three';
import { Viewer } from './Viewer';
//控制类型
enum CameraControlsEnabled
{
Rotate = 1,
Zoom = 2,
Pan = 4,
}
//相机控制状态
export enum CameraControlState
{

View File

@@ -1,4 +1,5 @@
import * as THREE from 'three';
import { LineBasicMaterial, MeshBasicMaterial, Color } from 'three';
const ColorPalette = [
[255, 0, 0, 255], //----- 0 - lets make it red for an example
//[255, 255, 255, 255],//----- 0 - ByBlock - White
@@ -270,19 +271,28 @@ export class ColorMaterial
{
private constructor() { }
private static m_LineMaterialMap = new Map<number, THREE.LineBasicMaterial>();
static GetLineMaterial(index): THREE.LineBasicMaterial
static GetLineMaterial(index): LineBasicMaterial
{
if (this.m_LineMaterialMap.has(index))
return this.m_LineMaterialMap.get(index);
let mat = new THREE.LineBasicMaterial({ color: this.GetColor(index) });
let mat = new LineBasicMaterial({ color: this.GetColor(index) });
this.m_LineMaterialMap.set(index, mat);
return mat;
}
private static m_BasicMaterialMap = new Map<number, MeshBasicMaterial>();
static GetBasicMaterial(index: number): MeshBasicMaterial
{
if (this.m_BasicMaterialMap.has(index))
return this.m_BasicMaterialMap.get(index);
let mat = new MeshBasicMaterial({ color: this.GetColor(index) });
this.m_BasicMaterialMap.set(index, mat);
return mat;
}
static GetColor(index: number)
{
let rgb = ColorPalette[index];
if (rgb)
return new THREE.Color(rgb[0] / 255, rgb[1] / 255, rgb[2] / 255);
return new Color(rgb[0] / 255, rgb[1] / 255, rgb[2] / 255);
}
}

View File

@@ -35,7 +35,7 @@ export class DbText extends Mesh
geometry.computeBoundingBox();
super(geometry, ColorMaterial.GetLineMaterial(5));
super(geometry, ColorMaterial.GetBasicMaterial(5));
let center = geometry.boundingBox.getCenter(new Vector3());
this.applyMatrix(MoveMatrix(new Vector3(-center.x, 0, 0)));

View File

@@ -43,7 +43,7 @@ export class Viewer
let mesh = PointPick(this, e.offsetX, e.offsetY);
if (oldMesh)
oldMesh.material = boardMaterial;
if (mesh && mesh.material !== ColorMaterial.GetLineMaterial(1))
if (mesh && mesh.material !== ColorMaterial.GetBasicMaterial(1))
{
oldMesh = mesh;
mesh.material = selectMaterial;

View File

@@ -171,7 +171,7 @@ export function createBoard(boardData: object)
geo.applyMatrix(boardMat);
let mesh = new Mesh(geo, ColorMaterial.GetLineMaterial(1));
let mesh = new Mesh(geo, ColorMaterial.GetBasicMaterial(1));
edges.push(mesh);
// let edge = createEdge(geo);
// edge.material = new LineBasicMaterial({ color: new Color(1, 0, 0) });