fix(test):threejs

This commit is contained in:
李正学 2018-11-01 14:31:14 +08:00
commit 7a16585897
7 changed files with 73 additions and 61 deletions

View File

@ -10,8 +10,9 @@ module.exports = {
include: [ include: [
'src/**/*.js', 'src/**/*.js',
'test/**/*.js', 'test/**/*.js',
'node_modules/three/' 'node_modules/three/**/*.js'
], ],
exclude: [], exclude: [
'node_modules/@babel/**/*.js'
]
} }

View File

@ -26,8 +26,8 @@ const scene = new L7.Scene({
mapStyle: 'light', // 样式URL mapStyle: 'light', // 样式URL
center: [ 120.1243238, 30.27331571 ], center: [ 120.1243238, 30.27331571 ],
pitch: 0, pitch: 0,
zoom: 19, zoom: 10,
minZoom: 16 minZoom: 9
}); });
window.scene = scene; window.scene = scene;
scene.image.addImage('bike', './image/Bike.png'); scene.image.addImage('bike', './image/Bike.png');
@ -43,11 +43,18 @@ scene.on('load', () => {
}) })
.size(128.0) .size(128.0)
.shape('image:bike') .shape('image:bike')
.color('#0198BD')
.render();
});
$.get('./data/fence.json', data => {
scene.PolygonLayer({
zIndex: 3
})
.source(data)
.shape('fill')
.color('#0198BD') .color('#0198BD')
.style({ .style({
stroke: 'rgb(255,255,255)', opacity:0.8
strokeWidth: 0,
opacity: 1.0
}) })
.render(); .render();
}); });

View File

@ -2,9 +2,9 @@
* @Author: ThinkGIS * @Author: ThinkGIS
* @Date: 2018-06-08 11:19:06 * @Date: 2018-06-08 11:19:06
* @Last Modified by: mikey.zhaopeng * @Last Modified by: mikey.zhaopeng
* @Last Modified time: 2018-10-30 11:13:39 * @Last Modified time: 2018-11-01 11:50:43
*/ */
const Base = require('./base'); import Base from './base';
const Controller = require('./controller/index'); const Controller = require('./controller/index');
import { aProjectFlat } from '../geo/project'; import { aProjectFlat } from '../geo/project';
export default class Source extends Base { export default class Source extends Base {

View File

@ -1,41 +1,43 @@
import 'three/src/polyfills.js'; // import 'three/src/polyfills.js';
export * from 'three/src/constants.js'; // export * from 'three/src/constants.js';
export { Scene } from 'three/src/scenes/Scene.js'; // export { Scene } from 'three/src/scenes/Scene.js';
export { WebGLRenderer } from 'three/src/renderers/WebGLRenderer.js'; // export { WebGLRenderer } from 'three/src/renderers/WebGLRenderer.js';
export { CanvasTexture } from 'three/src/textures/CanvasTexture.js'; // export { CanvasTexture } from 'three/src/textures/CanvasTexture.js';
export { Object3D } from 'three/src/core/Object3D.js'; // export { Object3D } from 'three/src/core/Object3D.js';
export { Points } from 'three/src/objects/Points.js'; // export { Points } from 'three/src/objects/Points.js';
export { LineSegments } from 'three/src/objects/LineSegments.js'; // export { LineSegments } from 'three/src/objects/LineSegments.js';
export { Mesh } from 'three/src/objects/Mesh.js'; // export { Mesh } from 'three/src/objects/Mesh.js';
export { Texture } from 'three/src/textures/Texture.js'; // export { Texture } from 'three/src/textures/Texture.js';
export { DirectionalLight } from 'three/src/lights/DirectionalLight.js'; // export { DirectionalLight } from 'three/src/lights/DirectionalLight.js';
export { AmbientLight } from 'three/src/lights/AmbientLight.js'; // export { AmbientLight } from 'three/src/lights/AmbientLight.js';
export { WebGLRenderTarget } from 'three/src/renderers/WebGLRenderTarget.js'; // export { WebGLRenderTarget } from 'three/src/renderers/WebGLRenderTarget.js';
export { PerspectiveCamera } from 'three/src/cameras/PerspectiveCamera.js'; // export { PerspectiveCamera } from 'three/src/cameras/PerspectiveCamera.js';
export { BufferGeometry } from 'three/src/core/BufferGeometry.js'; // export { BufferGeometry } from 'three/src/core/BufferGeometry.js';
export { Raycaster } from 'three/src/core/Raycaster.js'; // export { Raycaster } from 'three/src/core/Raycaster.js';
export { Matrix4 } from 'three/src/math/Matrix4.js'; // export { Matrix4 } from 'three/src/math/Matrix4.js';
export { Matrix3 } from 'three/src/math/Matrix3.js'; // export { Matrix3 } from 'three/src/math/Matrix3.js';
export { Line } from 'three/src/objects/Line.js'; // export { Line } from 'three/src/objects/Line.js';
export { LineLoop } from 'three/src/objects/LineLoop.js'; // export { LineLoop } from 'three/src/objects/LineLoop.js';
export { Vector4 } from 'three/src/math/Vector4.js'; // export { Vector4 } from 'three/src/math/Vector4.js';
export { Vector3 } from 'three/src/math/Vector3.js'; // export { Vector3 } from 'three/src/math/Vector3.js';
export { Vector2 } from 'three/src/math/Vector2.js'; // export { Vector2 } from 'three/src/math/Vector2.js';
export { TextureLoader } from 'three/src/loaders/TextureLoader.js'; // export { TextureLoader } from 'three/src/loaders/TextureLoader.js';
export { LineDashedMaterial } from 'three/src/materials/LineDashedMaterial.js'; // export { LineDashedMaterial } from 'three/src/materials/LineDashedMaterial.js';
export { ShaderMaterial } from 'three/src/materials/ShaderMaterial.js'; // export { ShaderMaterial } from 'three/src/materials/ShaderMaterial.js';
export { PointsMaterial } from 'three/src/materials/PointsMaterial.js'; // export { PointsMaterial } from 'three/src/materials/PointsMaterial.js';
export { VideoTexture } from 'three/src/textures/VideoTexture.js'; // export { VideoTexture } from 'three/src/textures/VideoTexture.js';
export { DataTexture } from 'three/src/textures/DataTexture.js'; // export { DataTexture } from 'three/src/textures/DataTexture.js';
export { // export {
Float64BufferAttribute, // Float64BufferAttribute,
Float32BufferAttribute, // Float32BufferAttribute,
Uint32BufferAttribute, // Uint32BufferAttribute,
Int32BufferAttribute, // Int32BufferAttribute,
Uint16BufferAttribute, // Uint16BufferAttribute,
Int16BufferAttribute, // Int16BufferAttribute,
Uint8ClampedBufferAttribute, // Uint8ClampedBufferAttribute,
Uint8BufferAttribute, // Uint8BufferAttribute,
Int8BufferAttribute, // Int8BufferAttribute,
BufferAttribute // BufferAttribute
} from 'three/src/core/BufferAttribute.js'; // } from 'three/src/core/BufferAttribute.js';
export * from '../../build/Three.js';

View File

@ -10,11 +10,12 @@ export default class PolygonLayer extends Layer {
} }
render() { render() {
this.type = 'polygon'; this.type = 'polygon';
const { opacity} = this.get('styleOptions');
this.init(); this.init();
const source = this.layerSource; const source = this.layerSource;
const geometry = this.geometry = new THREE.BufferGeometry(); const geometry = this.geometry = new THREE.BufferGeometry();
const lineMaterial = new LineMaterial({ const lineMaterial = new LineMaterial({
u_opacity: 1.0 u_opacity: opacity
} }
); );
const buffer = this.buffer = new PolygonBuffer({ const buffer = this.buffer = new PolygonBuffer({
@ -34,8 +35,9 @@ export default class PolygonLayer extends Layer {
if (this.shape === 'line') { if (this.shape === 'line') {
polygonMesh = new THREE.LineSegments(geometry, lineMaterial); polygonMesh = new THREE.LineSegments(geometry, lineMaterial);
} else { } else {
const material = new PolygonMaterial({ const material = new PolygonMaterial({
u_opacity: 1.0 u_opacity: opacity
}); });
geometry.addAttribute('normal', new THREE.Float32BufferAttribute(attributes.normals, 3)); geometry.addAttribute('normal', new THREE.Float32BufferAttribute(attributes.normals, 3));
// geometry.addAttribute('faceUv', new THREE.Float32BufferAttribute(attributes.faceUv, 2)); // geometry.addAttribute('faceUv', new THREE.Float32BufferAttribute(attributes.faceUv, 2));

View File

@ -1,5 +1,5 @@
import { expect } from 'chai'; import { expect } from 'chai';
import { LoadImage } from '../../../src/core/image'; import LoadImage from '../../../src/core/image';
describe('core LoadImage Test', function() { describe('core LoadImage Test', function() {
it('test create', function() { it('test create', function() {

View File

@ -24,12 +24,12 @@ module.exports = {
} }
} }
}, },
// { {
// test: /\.glsl$/, test: /\.glsl$/,
// use: { use: {
// loader: 'glsl-shaders-loader' loader: 'glsl-shaders-loader'
// } }
// }, },
{ {
test: /global\.js$/, test: /global\.js$/,
use: { use: {