Skip to content

Commit 778113d

Browse files
PANSTER.DanielPANSTER.Daniel
authored andcommitted
similar changes
1 parent a044031 commit 778113d

File tree

6 files changed

+250
-261
lines changed

6 files changed

+250
-261
lines changed

src/app/css3d-threejs/css3d-threejs.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ <h1>
66
<b>A Three.js CSS3d showcase...</b>
77
</h1>
88
This canvas contains two scenes from
9-
<em>THREE</em> js and two renderer elements, a
9+
<em>THREE.js</em> and two renderer elements, a
1010
<em>WebGLRenderer</em> and a
1111
<em>CSS3DRenderer</em>.
1212
<br> The focus is the integration and handling on the CSS 3d in the scene. Features for this showcase are clickable, highlight,

src/app/css3d-threejs/css3d-threejs.component.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ export class Css3dThreejsComponent implements AfterViewInit {
1515
@ViewChild('canvasCSS3d')
1616
private canvasRef: ElementRef;
1717

18-
private world:CSS3dWorld.MainCSS3d;
18+
private world: CSS3dWorld.MainCSS3d;
1919

2020

21-
/**
22-
* get the css3d canvas
23-
*
24-
* @readonly
25-
* @private
26-
* @type {HTMLDivElement}
27-
* @memberof Css3dThreejsComponent
28-
*/
21+
/**
22+
* get the css3d canvas
23+
*
24+
* @readonly
25+
* @private
26+
* @type {HTMLDivElement}
27+
* @memberof Css3dThreejsComponent
28+
*/
2929
private get canvas(): HTMLDivElement {
30-
return this.canvasRef.nativeElement;
30+
return this.canvasRef.nativeElement;
3131
}
3232

3333

@@ -44,15 +44,20 @@ export class Css3dThreejsComponent implements AfterViewInit {
4444
* @memberof Css3dThreejsComponent
4545
*/
4646
public ngAfterViewInit() {
47-
this.world = new CSS3dWorld.MainCSS3d(this.canvas, 0.7);
47+
this.world = new CSS3dWorld.MainCSS3d(this.canvas, 0.6);
48+
// this.canvasRef.nativeElement.style.position = 'relative';
49+
50+
// let domCanvas:HTMLCanvasElement = document.querySelector("canvas");
51+
// console.log(domCanvas);
52+
// domCanvas.style.position = 'relative';
4853
}
49-
50-
54+
55+
5156
/* EVENTS */
52-
/**
53-
* Update scene after resizing.
54-
*/
55-
public onResize() {
56-
this.world.onResize();
57+
/**
58+
* Update scene after resizing.
59+
*/
60+
public onResize() {
61+
this.world.onResize();
5762
}
5863
}

src/app/css3d-threejs/src/main.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,16 @@ export class MainCSS3d {
230230
this.scene.add(this.pivotPoint);
231231

232232
// Add different spheres with cannon shapes / bodies
233-
for (var i = 1; i < 3; i++) {
234-
for (var j = 1; j < 8; j++) {
233+
for (var i = 1; i < 8; i++) {
234+
for (var j = 1; j < 3; j++) {
235235
let factor = Math.random() * 30 + 5;
236236
console.log("factor: " + factor);
237237

238238
let sign: number = (factor > 20) ? +1 : -1; // positive or negative
239239
var sphereShape = new Cannon.Sphere(factor);
240240
var sphereBody = new Cannon.Body({ mass: factor });
241241
sphereBody.addShape(sphereShape);
242-
sphereBody.position.set(-450 + 140 * j, 70 * i+100, 20 * i * j - 150);
242+
sphereBody.position.set(j*50, 100 * i, 20 * i * j - 150);
243243
sphereBody.angularVelocity.set(0, factor / 100 * sign,0 );
244244
sphereBody.quaternion.set(0.2, 0.5, 0, 1);
245245
this.cannonBalls.push(sphereBody);
@@ -248,7 +248,7 @@ export class MainCSS3d {
248248
// visual
249249
var geom = new THREE.SphereGeometry(factor, 32, 32);
250250
var mesh = new THREE.Mesh(geom, this.getMeshPhongMaterialFromTexture(Texture.GAS_GREEN));
251-
mesh.position.set(-450 + 140 * j, 70 * i+100, 20 * i * j - 150);
251+
mesh.position.set(j*50 , 100 * i, 20 * i * j - 150);
252252
mesh.castShadow = true;
253253
mesh.receiveShadow = true;
254254
this.sceneBalls.push(mesh);

0 commit comments

Comments
 (0)