Skip to content

Commit

Permalink
Remaning changes to support new threejs version
Browse files Browse the repository at this point in the history
  • Loading branch information
fedegratti committed Oct 16, 2023
1 parent 8e322b5 commit 6b26364
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/data_textures/RGBDataTexture.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { RGBAFormat } from 'three';
import { CustomDataTexture } from './CustomDataTexture';
import { RGBFormat } from 'three';

class RGBDataTexture extends CustomDataTexture
{
constructor(width, height)
{
const data = new Uint8Array(width * height * 3);
super(data, width, height, RGBFormat);
super(data, width, height, RGBAFormat);
this.multiplier = 255;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/data_textures/RGBFloatDataTexture.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { FloatType, RGBAFormat } from 'three';
import { CustomDataTexture } from './CustomDataTexture';
import { FloatType } from 'three';
import { RGBFormat } from 'three';

class RGBFloatDataTexture extends CustomDataTexture
{
constructor(width, height)
{
const data = new Float32Array(width * height * 3);
super(data, width, height, RGBFormat, FloatType);
super(data, width, height, RGBAFormat, FloatType);
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/materials/SSAOMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { BlitMaterial } from '../materials/BlitMaterial';
import frag from '../shaders/ssao/ssao.frag';
import vert from '../shaders/ssao/ssao.vert';

import { Matrix4 } from 'three';
import { Vector3 } from 'three';
import { DataTexture } from 'three';
import { RGBFormat } from 'three';
import { RepeatWrapping } from 'three';
import { DataTexture, Matrix4, RGBAFormat, RepeatWrapping, Vector3 } from 'three';

import { OMath } from '../utilities/OMath';
class SSAOMaterial extends BlitMaterial
Expand Down Expand Up @@ -57,7 +53,7 @@ class SSAOMaterial extends BlitMaterial
rotation_kernel[i * 3 + 3] = 0;
}

const rotation_texture = new DataTexture(rotation_kernel, 4, 4, RGBFormat);
const rotation_texture = new DataTexture(rotation_kernel, 4, 4, RGBAFormat);
rotation_texture.wrapS = RepeatWrapping;
rotation_texture.wrapT = RepeatWrapping;

Expand Down
9 changes: 3 additions & 6 deletions src/primitives/Arrow.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { CylinderBufferGeometry } from 'three';
import { ConeBufferGeometry } from 'three';
import { MeshBasicMaterial } from 'three';
import { Vector3, Mesh } from 'three';
import { ConeGeometry, CylinderGeometry, Mesh, MeshBasicMaterial, Vector3 } from 'three';

import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js';

Expand All @@ -14,10 +11,10 @@ class Arrow extends Mesh

const cone_height = 0.4;
const cylinder_height = length - cone_height;
const cylinder_geo = new CylinderBufferGeometry(0.01, 0.01, cylinder_height, 32);
const cylinder_geo = new CylinderGeometry(0.01, 0.01, cylinder_height, 32);
cylinder_geo.translate(0, cylinder_height / 2, 0);

const cone_geometry = new ConeBufferGeometry(0.1, cone_height, 32);
const cone_geometry = new ConeGeometry(0.1, cone_height, 32);
cone_geometry.translate(0, cylinder_height + cone_height / 2, 0);

const buffer_geometry = BufferGeometryUtils.mergeBufferGeometries([cylinder_geo, cone_geometry]);
Expand Down
6 changes: 2 additions & 4 deletions src/primitives/Sphere.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { Mesh } from 'three';
import { SphereBufferGeometry } from 'three';
import { MeshBasicMaterial } from 'three';
import { Mesh, MeshBasicMaterial, SphereGeometry } from 'three';

class Sphere extends Mesh
{
constructor(radius, color)
{
color = color || '#FF0000';
radius = radius || 1;
const geometry = new SphereBufferGeometry(radius, 64, 64);
const geometry = new SphereGeometry(radius, 64, 64);
const material = new MeshBasicMaterial({ color: color });
super(geometry, material);
}
Expand Down
14 changes: 5 additions & 9 deletions src/render_mode/DeferredRender.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { CameraManager } from '../CameraManager';
import { SceneManager } from '../SceneManager';
import { Graphics } from '../Graphics';
import { OScreen } from '../OScreen';
import { BaseRender } from '../render_mode/BaseRender';
import { SceneManager } from '../SceneManager';
import { DeferredRendererComposeMaterial } from '../materials/DeferredRendererComposeMaterial';
import { Graphics } from '../Graphics';
import { DeferredPointLightMaterial } from '../materials/deferred/DeferredPointLightMaterial';
import { BaseRender } from '../render_mode/BaseRender';

import { WebGLRenderTarget } from 'three';
import { Scene } from 'three';
import { Mesh } from 'three';
import { SphereBufferGeometry } from 'three';
import { Matrix4 } from 'three';
import { Matrix4, Mesh, Scene, SphereGeometry, WebGLRenderTarget } from 'three';

class DeferredRender extends BaseRender
{
Expand All @@ -29,7 +25,7 @@ class DeferredRender extends BaseRender
const light_intensity = 1;
const light_brightest_component = 1;
const radius_needed_for_intensity = Math.sqrt(4 * light_intensity * (light_brightest_component * (256.0 / 5.0))) / (2 * light_intensity);
const sphere = new Mesh(new SphereBufferGeometry(radius_needed_for_intensity), new DeferredPointLightMaterial(light_intensity));
const sphere = new Mesh(new SphereGeometry(radius_needed_for_intensity), new DeferredPointLightMaterial(light_intensity));
// sphere.position.y = 2;
// this.scene_lights.add(sphere);

Expand Down
10 changes: 2 additions & 8 deletions src/static_batcher/GeometryBatch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import { Vector2 } from 'three';
import { ShaderMaterial } from 'three';
import { Mesh } from 'three';
import { DataTexture } from 'three';
import { RGBAFormat } from 'three';
import { RGBFormat } from 'three';
import { FloatType } from 'three';
import { DataTexture, FloatType, Mesh, RGBAFormat, ShaderMaterial, Vector2 } from 'three';

class GeometryBatch
{
Expand Down Expand Up @@ -242,7 +236,7 @@ class GeometryBatch
__create_rgb_texture(width)
{
const data = new Uint8Array(3 * width * width);
return new DataTexture(data, width, width, RGBFormat);
return new DataTexture(data, width, width, RGBAFormat);
}

__create_rgba_texture(width)
Expand Down

0 comments on commit 6b26364

Please sign in to comment.