Giter VIP home page Giter VIP logo

cesium-threejs-experiment's People

Contributors

analyticalgraphics avatar likangning93 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cesium-threejs-experiment's Issues

Can not use the new three.js version

while i use the new version of three.js such as :
import * as THREE from 'https://cdn.skypack.dev/three'

then can not add anything of three.js object in the canvas

about three.js vision

The function lookAt() in the Object3D in revision 88 and above of three.js has been changed, so there caught a problem that mesh can't be seen.
then I modified: "centerHigh = new THREE.Vector3(centerHigh.x, centerHigh.y, centerHigh.z)" at line 205 in CesiumThree.js .and it works.
After all, Cartesian3 can't be used as Vector3 at all situations.

The geometry disappeared when the camera changed

This sample code refers to cesium-threejs-experiment,but the geometry disappeared when the camera changed.

class ThreeJSPrimitive {
constructor(options) {
this.geometry = null;
this.combineGeometry([options.geometryInstance]);
var geometry = new THREE.BufferGeometry();
geometry.addAttribute('position2DHigh', new THREE.BufferAttribute(this.geometry.attributes.position2DHigh.values, 3));
geometry.addAttribute('position2DLow', new THREE.BufferAttribute(this.geometry.attributes.position2DLow.values, 3));
geometry.setIndex(new THREE.BufferAttribute(this.geometry.indices, 1));

     var vertexShader = `attribute vec3 position2DHigh;
        attribute vec3 position2DLow;
        varying vec3 v_pos;
        void main(){
            v_pos=position2DHigh.zxy+position2DLow.zxy;
            gl_Position = projectionMatrix * modelViewMatrix * vec4(v_pos,1.0);
        }`;
     var fragmentShader = `varying vec3 v_pos;
        void main(){      
            vec4 color;
            if(v_pos.x>2000000.0){
                color=vec4(1.0,1.0,1.0,1.0);
            }else{
                 color=vec4(1.0,0.0,0.0,1.0);
            }       
            gl_FragColor = color*color.a;
        }`;
     this.scene = new THREE.Scene();
     this.material = new THREE.ShaderMaterial({
         vertexShader: vertexShader,
         fragmentShader: fragmentShader,
         //side: THREE.DoubleSide,
         //depthTest: false,
         //blending: THREE.NoBlending,
         depthWrite: false,
         //transparent: true,
         uniforms: {}
     });

     var cubeMesh = new THREE.Mesh(geometry, this.material);
     this.scene.add(cubeMesh);
 }
 combineGeometry(geometris) {
     var projection = new Cesium.WebMercatorProjection(Cesium.Ellipsoid.WGS84);
     var result = Cesium.PrimitivePipeline.combineGeometry({
         instances: geometris,
         ellipsoid: projection.ellipsoid,
         projection: projection,
         elementIndexUintSupported: true,
         scene3DOnly: false,
         vertexCacheOptimize: false,
         compressVertices: true,
         modelMatrix: this.modelMatrix
     });
     this.geometry = result.geometries[0];
     this.attributeLocations = result.attributeLocations;
     this.modelMatrix = Cesium.Matrix4.clone(result.modelMatrix, this.modelMatrix);
 }

 update(frameState) {
     if (!this.renderer) {
         this.renderer = new THREE.WebGLRenderer({
             canvas: document.getElementById('cube'),
             alpha: true
         });
         this.renderer.autoClear = true;
     }

     var camera = frameState.camera;
     if (!this.camera) {
         this.camera = new THREE.PerspectiveCamera(camera.frustum.fov, camera.frustum.aspectRatio, camera.frustum.near, camera.frustum.far);
         //this.camera = new THREE.Camera();
     }

     this.camera.projectionMatrix = new THREE.Matrix4().fromArray(camera.frustum.projectionMatrix);
     this.camera.matrix = new THREE.Matrix4().getInverse(new THREE.Matrix4().fromArray(camera.viewMatrix));
     this.camera.matrix.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);
     this.renderer.state.reset();
     this.renderer.render(this.scene, this.camera);
 }

}

var polygon = new Cesium.PolygonGeometry({
polygonHierarchy: new Cesium.PolygonHierarchy(
Cesium.Cartesian3.fromDegreesArray(degreesArray)
),
height: maxHeight,
extrudedHeight: 0
});
var geometry = Cesium.PolygonGeometry.createGeometry(polygon);
var geoInstance = new Cesium.GeometryInstance({
geometry: geometry
});
var primitive3 = new ThreeJSPrimitive({
geometryInstance: geoInstance
});
viewer.scene.primitives.add(primitive3);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.