Skip to content

Commit ae3f230

Browse files
author
aardgoose
committed
wip
1 parent f9221f6 commit ae3f230

11 files changed

Lines changed: 262 additions & 176 deletions

File tree

package-lock.json

Lines changed: 211 additions & 157 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
"x18n": "^2.0.3"
5353
},
5454
"dependencies": {
55-
"acorn-walk": "^8.2.0"
55+
"acorn-walk": "^8.2.0",
56+
"escope": "^4.0.0",
57+
"estree-toolkit": "^1.7.3"
5658
}
5759
}

rollup-plugin-three-nodes.mjs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { simple } from 'acorn-walk';
2+
import { traverse } from 'estree-toolkit';
23

34
const nodeElements = {};
45

56
export default function threeNodes () {
67

78
return {
9+
810
name: 'three-nodes', // this name will show up in logs and errors
911

1012
transform: {
@@ -22,16 +24,24 @@ export default function threeNodes () {
2224
const newImports = [];
2325
const currentImports = {};
2426

25-
simple( ast, {
2627

27-
ImportSpecifier( node ) {
28+
// simple( ast, {
29+
traverse( ast, {
30+
31+
$: { scope: true },
32+
33+
ImportSpecifier ( nodepath ) {
34+
35+
const node = nodepath.node;
2836

2937
// track file's current imports
3038
currentImports[ node.imported.name ] = true;
3139

3240
},
3341

34-
CallExpression ( node ) {
42+
CallExpression ( nodepath ) {
43+
44+
const node = nodepath.node;
3545

3646
if ( node.callee.type == 'Identifier' && node.callee.name == 'addNodeElement' ) {
3747

@@ -57,6 +67,9 @@ export default function threeNodes () {
5767
newImports.push( `import { ${propertyName} } from '${moduleId.replaceAll( '\\', '\/' ) }';` );
5868
newImports.push( `console.log( 'custard:', ${propertyName});` );
5969

70+
console.log( "\n\nfile:", fileName, "\nprop:", propertyName, "\n" ,nodepath.scope );
71+
console.log( "\nparent", nodepath.parent);
72+
6073
delete nodeElements[ propertyName ];
6174

6275
}

src/js/Three.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ ColorManagement.enabled = true;
8888
Object3D.onUploadDropBuffer = function () {
8989

9090
// call back from BufferAttribute to drop JS buffers after data has been transfered to GPU
91-
// this.array = null;
91+
this.array = new this.array.constructor( 1 );
9292

9393
};
9494

@@ -113,4 +113,5 @@ Object3D.prototype.dropBuffers = function ( colors = true ) {
113113

114114
if ( geometry.index ) geometry.index.onUpload( Object3D.onUploadDropBuffer );
115115

116-
};
116+
};
117+
export { Object3D };

src/js/materials/ClusterMaterial.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { CanvasTexture } from '../Three';
2-
import { SpriteNodeMaterial } from '../Nodes';
2+
import { PopupMaterial } from './PopupMaterial';
33

4-
class ClusterMaterial extends SpriteNodeMaterial {
4+
class ClusterMaterial extends PopupMaterial {
55

6-
constructor ( params ) {
6+
constructor ( params, cvCtx ) {
77

88
const count = params.count;
99

@@ -49,8 +49,11 @@ class ClusterMaterial extends SpriteNodeMaterial {
4949

5050
const texture = new CanvasTexture( canvas );
5151

52-
super( { map: texture, depthTest: false, transparent: true, alphaTest: 0.8, sizeAttenuation: false } );
52+
super( cvCtx.container, texture );
5353

54+
//super( { map: texture, depthTest: false, transparent: true, alphaTest: 0.8, sizeAttenuation: false } );
55+
56+
// this.scaleNode = float( 4 );
5457
//texture.onUpdate = function _dropCanvas ( texture ) { texture.image = null; };
5558

5659
}

src/js/materials/DepthMaterial.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DepthMaterial extends SubsurfaceMaterial {
2121
// FIXME double check all depth calcs
2222
const depth = terrainHeight( positionLocal ).sub( positionLocal.z ).mul( du.depthScale );
2323

24-
this.colorNode = texture( textureCache.getTexture( gradient ), vec2( depth, 1.0 ) ); // FIXME vertex colot
24+
this.colorNode = texture( textureCache.getTexture( gradient ), vec2( depth, 1.0 ) ); // FIXME vertex color
2525

2626
}
2727

src/js/materials/GlyphAtlas.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CanvasTexture, LinearFilter, NearestFilter } from '../Three';
1+
import { CanvasTexture, NearestFilter } from '../Three';
22

33
class GlyphAtlas {
44

@@ -58,7 +58,7 @@ class GlyphAtlas {
5858

5959
const texture = new CanvasTexture( canvas );
6060

61-
texture.minFilter = LinearFilter;
61+
texture.minFilter = NearestFilter;
6262
this.generateMipmaps = false;
6363

6464
function addGlyphToCanvas ( glyph, i ) {

src/js/materials/PopupMaterial.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,25 @@ class PopupMaterial extends NodeMaterial {
1818
this.generateMipmaps = false;
1919

2020
const pixelRatio = window.devicePixelRatio || 1;
21-
const canvas = popupImage.image;
21+
22+
let { width, height } = popupImage.image;
23+
24+
if ( popupImage.isCanvasTexture ) {
25+
26+
width *= pixelRatio;
27+
height *= pixelRatio;
28+
29+
}
2230

2331
// const cos = Math.cos( rotation );
2432
// const sin = Math.sin( rotation );
33+
2534
// const rotationMatrix = new Float32Array( [ cos, sin, -sin, cos ] );
35+
2636
this.vertexNode = new ShaderNode( ( stack ) => {
2737

2838
const viewPort = new Vector2( Math.floor( pixelRatio * container.clientWidth ) / 2, Math.floor( pixelRatio * container.clientHeight ) / 2 );
29-
const scale = new Vector2( canvas.width, canvas.height ).divide( viewPort );
39+
const scale = new Vector2( width, height ).divide( viewPort );
3040

3141
// const rotate = uniform( mat2( cos, sin, -sin, cos ) );
3242

src/js/terrain/CommonTerrain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ class CommonTerrain extends Group {
321321
}
322322

323323
getHeight ( point ) {
324-
324+
return 0;
325325
return this.heightLookup.lookup( point );
326326

327327
}

src/js/viewer/Marker.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { ClusterMaterial } from '../materials/ClusterMaterial';
2-
import { Sprite } from '../Three';
2+
import { Popup } from '../ui/Popup';
33

4-
class Marker extends Sprite {
4+
class Marker extends Popup {
55

66
isMarker = true;
77

88
constructor ( ctx, count ) {
99

10-
super( ctx.materials.getMaterial( ClusterMaterial, { count: count } ) );
10+
super();
11+
12+
this.material = ctx.materials.getMaterial( ClusterMaterial, { count: count } );
1113
this.renderOrder = 1;
1214
this.scale.set( 100, 100 );
1315

0 commit comments

Comments
 (0)