Skip to content

Commit

Permalink
Merge pull request #160 from treblereel/r105
Browse files Browse the repository at this point in the history
R105
  • Loading branch information
treblereel authored Jun 29, 2020
2 parents dd759d4 + 4a2d758 commit 58034ad
Show file tree
Hide file tree
Showing 61 changed files with 3,738 additions and 2,609 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
## A Three.js wrapper for GWT

# Maven
Current Version 0.104, implements 0.104 version of three.js
Current Version 0.105, implements 0.105 version of three.js

```xml
<dependency>
<groupId>org.treblereel.gwt</groupId>
<artifactId>three4g</artifactId>
<version>0.104</version>
<version>0.105</version>
</dependency>
```
# Setup
Expand Down
2 changes: 1 addition & 1 deletion annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.treblereel.gwt</groupId>
<artifactId>three4g-parent</artifactId>
<version>0.105-SNAPSHOT</version>
<version>0.106-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.treblereel.gwt</groupId>
<artifactId>three4g-parent</artifactId>
<version>0.105-SNAPSHOT</version>
<version>0.106-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* See the base @see {@link Camera} class for common properties.
* Note that after making changes to most of these poperties you will have to call .updateProjectionMatrix for the changes
* to take effect.
*
* @author Dmitrii Tikhomirov
* Created by treblereel on 12/6/17.
*/
Expand All @@ -25,9 +24,9 @@ public class PerspectiveCamera extends Camera {
public float aspect;

/**
* bounds
* viewport
*/
public Vector4 bounds;
public Vector4 viewport;

/**
* Camera frustum far plane. Default is 2000.
Expand Down Expand Up @@ -88,34 +87,34 @@ public PerspectiveCamera() {

/**
* @param fov — Camera frustum vertical field of view.
* Together these define the camera's viewing frustum.
* Together these define the camera's viewing frustum.
*/
public PerspectiveCamera(float fov) {
}

/**
* @param fov — Camera frustum vertical field of view.
* @param fov — Camera frustum vertical field of view.
* @param aspect — Camera frustum aspect ratio.
* Together these define the camera's viewing frustum.
* Together these define the camera's viewing frustum.
*/
public PerspectiveCamera(float fov, float aspect) {
}

/**
* @param fov — Camera frustum vertical field of view.
* @param fov — Camera frustum vertical field of view.
* @param aspect — Camera frustum aspect ratio.
* @param near — Camera frustum near plane.
* Together these define the camera's viewing frustum.
* @param near — Camera frustum near plane.
* Together these define the camera's viewing frustum.
*/
public PerspectiveCamera(float fov, float aspect, float near) {
}

/**
* @param fov — Camera frustum vertical field of view.
* @param fov — Camera frustum vertical field of view.
* @param aspect — Camera frustum aspect ratio.
* @param near — Camera frustum near plane.
* @param far — Camera frustum far plane.
* Together these define the camera's viewing frustum.
* @param near — Camera frustum near plane.
* @param far — Camera frustum far plane.
* Together these define the camera's viewing frustum.
*/
public PerspectiveCamera(float fov, float aspect, float near, float far) {
}
Expand All @@ -127,38 +126,33 @@ public PerspectiveCamera(float fov, float aspect, float near, float far) {

/**
* Returns the current vertical field of view angle in degrees considering .zoom.
*
* @return as float value
*/
public native float getEffectiveFOV();

/**
* Returns the height of the image on the film. If .aspect is less than or equal to one (portrait format),
* the result equals .filmGauge.
*
* @return as float value
*/
public native float getFilmHeight();

/**
* Returns the width of the image on the film. If .aspect is greater than or equal to one (landscape format),
* the result equals .filmGauge.
*
* @return as float value
*/
public native float getFilmWidth();

/**
* Returns the focal length of the current .fov in respect to .filmGauge.
*
* @return as float value
*/
public native float getFocalLength();

/**
* Sets the FOV by focal length in respect to the current .filmGauge.
* <p>
*
* @param focalLength By default, the focal length is specified for a 35mm (full frame) camera.
*/
public native void setFocalLength(float focalLength);
Expand Down Expand Up @@ -190,13 +184,12 @@ public PerspectiveCamera(float fov, float aspect, float near, float far) {
* camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
* // F
* camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); Note there is no reason monitors have to be the same size or in a grid.
*
* @param fullWidth — full width of multiview setup
* @param fullWidth — full width of multiview setup
* @param fullHeight — full height of multiview setup
* @param x — horizontal offset of subcamera
* @param y — vertical offset of subcamera
* @param width — width of subcamera
* @param height — height of subcamera
* @param x — horizontal offset of subcamera
* @param y — vertical offset of subcamera
* @param width — width of subcamera
* @param height — height of subcamera
*/
public native void setViewOffset(float fullWidth, float fullHeight, float x, float y, float width, float height);

Expand All @@ -207,7 +200,6 @@ public PerspectiveCamera(float fov, float aspect, float near, float far) {

/**
* Return camera data in JSON format.
*
* @return String
*/
public native String toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,11 @@ public BufferAttribute(TypedArray array, int itemSize, boolean normalized) {
*/
public native T setXYZW(int index, V x, V y, V z, V w);

/**
* Return BufferAttribute data in JSON format.
*
* @return String
*/
public native String toJSON();

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ public class InstancedBufferGeometry extends BufferGeometry {
*/
public boolean isInstancedBufferGeometry;


/**
* Return InstancedBufferGeometry data in JSON format.
*
* @return String
*/
public native String toJSON();
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ public Object3D() {
*/
public native void applyQuaternion(Quaternion quaternion);

/**
* Adds object as a child of this, while maintaining the object's world transform.
* @param object3D an Object3D
* @return this instance of Object3D
*/
public native Object3D attach(Object3D object3D);

/**
* Returns a clone of this object and optionally all descendants.
*
Expand Down
21 changes: 21 additions & 0 deletions core/src/main/java/org/treblereel/gwt/three4g/math/Matrix4.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,27 @@ public Matrix4(){
*/
public native Matrix4 setPosition(Vector3 v);

/**
* Sets the position component for this matrix from vector v, without affecting the rest of the matrix - i.e. if the matrix is currently:
* a, b, c, d,
* e, f, g, h,
* i, j, k, l,
* m, n, o, p
*
* This becomes:
* a, b, c, v.x,
* e, f, g, v.y,
* i, j, k, v.z,
* m, n, o, p
*
* @param x float value
* @param y float value
* @param z float value
* @return instance of Matrix4
*/
public native Matrix4 setPosition(float x, float y, float z);


/**
* Writes the elements of this matrix to an array in column-major format.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.treblereel.gwt.three4g.math;

import jsinterop.annotations.JsType;

/**
* Represents a third-order spherical harmonics (SH). Light probes use this class to encode lighting information.
* @author Dmitrii Tikhomirov
* Created by treblereel 6/28/20
*/
@JsType(isNative = true, namespace = "THREE")
public class SphericalHarmonics3 {

/**
Expand Down Expand Up @@ -91,22 +94,22 @@ public class SphericalHarmonics3 {

/**
* Returns an array with the coefficients, or copies them into the provided array. The coefficients are represented as numbers.
* @return
* @return instance of Vector3[]
*/
public native Vector3[] toArray();

/**
* Returns an array with the coefficients, or copies them into the provided array. The coefficients are represented as numbers.
* @param array - (optional) The target array.
* @return
* @return instance of Vector3[]
*/
public native Vector3[] toArray(Vector3[] array);

/**
* Returns an array with the coefficients, or copies them into the provided array. The coefficients are represented as numbers.
* @param array - (optional) The target array.
* @param offset - (optional) The array offset.
* @return
* @return instance of Vector3[]
*/
public native Vector3[] toArray(Vector3[] array, int offset);

Expand Down
18 changes: 9 additions & 9 deletions core/src/main/java/org/treblereel/gwt/three4g/math/Triangle.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

/**
* A geometric triangle as defined by three Vector3s representing its three corners.
*
* @author Dmitrii Tikhomirov
* Created by treblereel on 5/30/18.
*/
Expand All @@ -28,7 +27,6 @@ public class Triangle {

/**
* Creates a new Triangle.
*
* @param a - the first corner of the triangle. Default is a Vector3 at (0, 0, 0).
* @param b - the second corner of the triangle. Default is a Vector3 at (0, 0, 0).
* @param c - the final corner of the triangle. Default is a Vector3 at (0, 0, 0).
Expand All @@ -37,13 +35,15 @@ public Triangle(Vector3 a, Vector3 b, Vector3 c) {

}

public native static boolean isFrontFacing(Vector3 a, Vector3 b, Vector3 c, Vector3 direction);

/**
* @return Returns a new triangle with the same a, b and c properties as this one.
*/
public native Triangle clone();

/**
* @param point - Vector3
* @param point - Vector3
* @param target — the result will be copied into this Vector3.
* @return Returns the closest point on the triangle to point.
*/
Expand All @@ -57,7 +57,6 @@ public Triangle(Vector3 a, Vector3 b, Vector3 c) {

/**
* Copies the values of the passed triangles's a, b and c properties to this triangle.
*
* @param triangle instance of Triangle
* @return instance of Triangle
*/
Expand All @@ -75,7 +74,7 @@ public Triangle(Vector3 a, Vector3 b, Vector3 c) {
public native float getArea();

/**
* @param point - Vector3
* @param point - Vector3
* @param target — the result will be copied into this Vector3.
* @return Return a barycentric coordinate from the given vector.
*/
Expand Down Expand Up @@ -115,12 +114,13 @@ public Triangle(Vector3 a, Vector3 b, Vector3 c) {

/**
* Sets the triangle's vectors to the vectors in the array.
*
* @param points - Array of Vector3s
* @param i0 - Integer index
* @param i1 - Integer index
* @param i2 - Integer index
* @param i0 - Integer index
* @param i1 - Integer index
* @param i2 - Integer index
* @return instance of Triangle
*/
public native Triangle setFromPointsAndIndices(Vector3[] points, int i0, int i1, int i2);

public native boolean isFrontFacing(Vector3 direction);
}
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,21 @@ public final double getHeight() {
* @param buffer instance of Uint8Array
*/
public native void readRenderTargetPixels(WebGLRenderTarget renderTarget, float x, float y, float width, float height, Uint8Array buffer);
/**
* Reads the pixel data from the renderTarget into the buffer you pass in. Buffer should be a Javascript Uint8Array
* instantiated with new Uint8Array( renderTargetWidth * renderTargetWidth * 4 ) to account for size and color information.
* This is a wrapper around gl.readPixels.
* See the interactive / cubes / gpu example.
* @param renderTarget instance of WebGLRenderTarget
* @param x as float
* @param y as float
* @param width as float
* @param height as float
* @param buffer instance of Uint8Array
* @param readRenderTargetPixels as int
*/
public native void readRenderTargetPixels(WebGLRenderTarget renderTarget, float x, float y, float width, float height, Uint8Array buffer, int readRenderTargetPixels);


/**
* Render a scene using a camera.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ public class WebGLRendererParameters {
public String powerPreference; // Can be "high-performance", "low-power" or "default"
public boolean depth;
public boolean logarithmicDepthBuffer;
public boolean failIfMajorPerformanceCaveat;

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class WebXRManager {

public boolean isPresenting;

public String frameOfReferenceType;
public String referenceSpaceType;

public WebXRManager(WebGLRenderer renderer){

Expand Down
Loading

0 comments on commit 58034ad

Please sign in to comment.