Giter Site home page Giter Site logo

react-native-webgl's Introduction

react-native-webgl is deprecated

Since react-native-unimodules was introduced we can now use Expo modules like expo-gl which is where the webgl implementation has been continued and is actively maintained.

We therefore recommend you now move to use expo-gl:

You will need a react-native-unimodules setup

yarn add react-native-unimodules

If it's the first time you install react-native-unimodules, you will have to carefully follow the documentation to configure your project: configure unimodules (if not yet done)

You can then install expo-gl dependencies:

yarn add expo-gl expo-gl-cpp

If you use gl-react-native

Upgrade to latest version of gl-react-native that now depends on expo-gl and expo-gl-cpp (you don't need to install it, it also won't depend on this package anymore).

react-native-webgl's People

Contributors

derolf avatar epochrion avatar futuun avatar gre avatar ijzerenhein avatar jeremymcolegrove avatar johannth avatar kelset avatar ni55an avatar st0ffern avatar vaukalak avatar volodymyrlut 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

react-native-webgl's Issues

how to improve performance in iOS Simulator?

the current performance you get on iOS simulator is quite bad, making really difficult to develop anything WebGL with the simulator.
i'm not sure what we can improve, if it's related to JSC or OpenGL. But I'm pretty sure OpenGL can be performant even in simulator, see for instance examples of gl-react-native v2 (that was doing custom opengl impl in ObjC but not actually implementing webgl api)

iOS throw Exception

gl-react: 3.13.0
gl-react-native: 3.13.0
react-native-webgl: 0.8.0
react-native: 0.44.3

Running on iOS, the following error appears, looking forward to the author reply as soon as possible

1517282845846

inspire from headless-gl

there are some good technique to inspire from https://github.com/stackgl/headless-gl i think

especially their webgl.js they do much more "js caching" than we do and it could be beneficial for perfs.

I even wonder if we should take more look at their native implementation, could we literally make it run in RN ? (it depends on node.js)

Error about es2015, stage-1 and react babel presets not installed

The react native gives an error that it couldn't find the es2015, stage-1 and react presets, like the one below:

error: bundling failed: "TransformError: /Users/suhairzain/Documents/test-app/node_modules/react-native-webgl/lib/index.js: Couldn't find preset \"es2015\" relative to directory \"/Users/suhairzain/Documents/test-app/node_modules/react-native-webgl\""

Right now, I've managed to get it working by installing these as a dev dependency for my project, but what would be the right way to fix this issue?

Exception thrown when unloading

The following code :

-(void)unloadWithCtxId:(RNWebGLContextId)ctxId {
  for (NSNumber *key in [_objects keyEnumerator]) {
    RNWebGLTexture *t = _objects[key];
    if (t.ctxId == ctxId) {
      [t unload];
      [_objects removeObjectForKey:key];
    }
  }
}

from RNWebGLTextureLoader.m throws this exception :

'*** Collection <__NSDictionaryM: 0x1708484c0> was mutated while being enumerated.'

The exception seems to be thrown only when the code is live reloading.

Cannot add gradle-download-task to build.gradle

Hi,

I'm trying to add react-native-webgl to our app. But the build for android is failing. Precisely, when I run react-native run-android, it fails at downloadJSCHeaders.
The error is as follows:

:react-native-webgl:createNativeDepsDirectories UP-TO-DATE
:react-native-webgl:downloadJSCHeaders FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-webgl:downloadJSCHeaders'.
> Could not initialize class org.apache.http.conn.ssl.SSLConnectionSocketFactory

As stated in the README, I added gradle-download-task in build.gradle. However since we are using Gradle with version 3.3, I added the plugin as follows:

// for react-native-webgl
plugins {
    id "de.undercouch.download" version "3.1.2"
}

Do you have an idea?

Android flickering

I'm linking to this issue I posted on the Expo repo:

expo/expo#868

The issue is flickering on Android when the js is too slow for the onDrawFrame method of the GLSurfaceView.
We need some kind of clean synchronization between the JS and Java (see the suggestion I posted there).

Any way to use OrbitControls from THREE.JS?

Hi guys,
I am testing the THREE.JS here and it is working, but I was wondering if would be possible to use the OrbitControls (rotate, zoom, etc) from THREE.JS at the camera with react-native-webgl.
Is there any way to make it work instead of handling the touches by React Native?

File 'libRNWebGL.a' doesn't exist

I followed the installation instructions, but I can't add libRNWebGL.a to my project because it doesn't exist anywhere in the node_modules folder.

RN0.44.3 Crash

init new RN0.44.3 project

try

import React, { Component } from "react";
import { WebGLView } from "react-native-webgl";
class RedSquareWebGL extends Component {
  onContextCreate = (gl: WebGLRenderingContext) => {
    const rngl = gl.getExtension("RN");
    gl.clearColor(1, 0, 0, 1);
    gl.clear(gl.COLOR_BUFFER_BIT);
    rngl.endFrame();
  };
  render() {
    return (
      <WebGLView
        style={{ width: 100, height: 100 }}
        onContextCreate={this.onContextCreate}
      />
    );
  }
}

Crash!

Any advice would be appreciated

Use with Three.js

Hello,

Can this library be used straight out with Three.js ? If so, could you provide a minimal example on how to do so ?

Thank you very much.

Android build failing: fr.greweb.rnwebgl does not exist

I keep hitting a build error with react-native run-android command:

MainApplication.java:6:
package fr.greweb.rnwebgl does not exist
import fr.greweb.rnwebgl.RNWebGLPackage;

after installing the dependencies with yarn, I linked them via react-native link react-native-webgl and made the other necessary modifications.

Why does the import fail in finding the source for the import like this? What did I do wrong here?

Memory Leak Issue

I have run into an issue related to a memory leak. Effectively, after having disposed of a mesh (along with any linked geometry, texture, or material) and after ensuring that there are no longer any references to the mesh, the allocated space in memory is never freed when the garbage collector runs. Consequently, the application crashes should sufficient meshes have been created and later disposed.

For reference, I have uploaded sample code that illustrates this issue. The linked example creates a mesh using an image texture every 60 frames. The mesh is then deleted 30 frames after it is created. This process repeats indefinitely. If a memory profiler is attached to the process, it can be noticed that the allocated memory always continues to increase rather than fluctuating and stabilizing around a central value as may be expected. Find linked an image from a memory profiler that was attached to the above example code.

More details related to the testing that was conducted are listed below:

Testing Scenario Significant Memory Leak Present?
1 🔵 No
2 🔵 No
3 🔴 Yes
4 🔴 Yes
5 🔵 No

The testing scenarios as numbered in the table above are:

  1. Empty React Native Application, without react-native-webgl or Three JS
  2. React Native Application, with PanResponder, and an empty Three JS scene
  3. React Native Application, as per the example code above, but never calling disposeImage()
  4. React Native Application, exactly as per the example code above, and calling disposeImage()
  5. HTML Web Page, using only Three JS, with almost the exact same code as the above example

I believe the issue is related to the react-native-webgl library, and it is not related to Three JS due to scenario 5 above. With the exception of how the image itself is loaded due to a difference in target platform, the rest of the code in scenario 5 is almost the same as in scenario 4. Yet, the memory leak example is present in scenario 4 and not in scenario 5. Find linked sample code for scenario 5.

It is also interesting to note that the amount of memory allocated after 1 minute 30 seconds is approximately 60-65 MB in scenario 3, and is approximately 95-100 MB in scenario 4. There appears to be a noticeable increase in the memory leak when scene.remove(mesh) is called versus when it is not called.

From the testing conducted, I wonder if the react-native-webgl library is keeping a reference to the created texture or mesh somewhere, and hence preventing the allocated memory from being freed?

Trying to load obj & mtl file with Three.js

Note: This is not an issue with this library but I was hoping I will get an answer here, hence posting it.
Main objective : Load animated models exported from Maya into React Native app
Exported files : obj, mtl & png file

When I am trying to load the MTL file using the MTLLoader, I am getting following error:

Can't find variable: document

Here are the two files that I am using:

three.js

const THREE = require("three");
global.THREE = THREE;
if (!window.addEventListener)
window.addEventListener = () => { };
// require("three/examples/js/renderers/Projector");
require("three/examples/js/loaders/MTLLoader");
require("three/examples/js/loaders/OBJLoader");
export default THREE;

ThreeView.js

import React, { Component } from "react";
import { StyleSheet, View } from "react-native";
import { WebGLView } from "react-native-webgl";
import THREE from "./three";
import { image } from "src/res/image";

export default class ThreeView extends Component {
requestId: *;
componentWillUnmount() {
cancelAnimationFrame(this.requestId);
}
onContextCreate = (gl: WebGLRenderingContext) => {
const rngl = gl.getExtension("RN");

    const { drawingBufferWidth: width, drawingBufferHeight: height } = gl;
    const renderer = new THREE.WebGLRenderer({
        canvas: {
            width,
            height,
            style: {},
            addEventListener: () => { },
            removeEventListener: () => { },
            clientHeight: height
        },
        context: gl
    });
    renderer.setSize(width, height);
    renderer.setClearColor(0xffffff, 1);

    let camera, scene;

    function init() {
        camera = new THREE.PerspectiveCamera(75, width / height, 1, 1100);
        camera.position.y = 150;
        camera.position.z = 500;
        scene = new THREE.Scene();

        var mtlLoader = new THREE.MTLLoader();
        mtlLoader.load('female-croupier-2013-03-26.mtl', function (materials) {
            materials.preload();
            
            var objLoader = new THREE.OBJLoader();
            objLoader.setMaterials(materials);
            objLoader.load('female-croupier-2013-03-26.obj', function (object) {
                scene.add(object);
            }, onLoading, onErrorLoading);
        }, onLoading, onErrorLoading);
    }
    const onLoading = (xhr) => {
        console.log((xhr.loaded / xhr.total * 100) + '% loaded');
    };
    const onErrorLoading = (error) => {
        console.log('An error happened', error);
    };
    const animate = () => {
        this.requestId = requestAnimationFrame(animate);
        renderer.render(scene, camera);

        gl.flush();
        rngl.endFrame();
    };

    init();
    animate();
};
render() {
    return (
        <View style={styles.container}>
            <WebGLView
                style={styles.webglView}
                onContextCreate={this.onContextCreate}
            />
        </View>
    );
}

}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
},
webglView: {
width: 300,
height: 300
}
});

webgl2

Any plans for webgl2 support ?

Preloading textures

Hi,

I'd like to have more control on when exactly images are preloaded for textures. I use webGL to make a picture black&white is the user is not present. This image is on the background of a view. When the view animates in, it takes a second for the texture to load. How can I preload this?

I tried to implement a preloader but I can't seem to do this without a contextId. Can I make a standalone preloader that manages which textures are kept in memory and clean them accordingly? Any fragment shader requiring them is then just synchronous.

Cheers

Videos as textures

Is it possible to use an AVPlayer to provide a dynamic texture with this ?

iOS : Textures not loading on first render (ThreeJS)

On iOS only, I noticed that my textured meshes do not show on the first render of my WebGL component, but show correctly on every subsequent render.

Component code :

  onContextCreate = (gl) => {
    this.width = 4;
    this.height = (metrics.height / metrics.width) * this.width;
    this.camera = createCamera(this.width, this.height);
    this.gl = gl;
    this.renderer = createRenderer({ gl });
    this.renderer.setSize(gl.drawingBufferWidth, gl.drawingBufferHeight);
    const context = gl.getExtension('RN');

    this.createScene();

    const animate = () => {
      requestAnimationFrame(animate);

      this.renderer.render(this.scene, this.camera);

      context.endFrame();
    };

    animate();
  };

  createScene = () => {
    this.scene = new THREE.Scene();

    this.background = meshes.createBackground((2000 / metrics.width) * this.width, this.height, this.gl, this.renderer);
    this.plane = meshes.createPlane(this.gl, this.renderer);

    this.scene.add(this.background);
    this.scene.add(this.plane);
  };


  panResponder = PanResponder.create({
    onStartShouldSetPanResponder: () => true,
    onPanResponderGrant: this.touch,
  });


  render() {
    return (
      <WebGLView
        {...this.panResponder.panHandlers}
        style={{ width: metrics.width, height: metrics.height }}
        onContextCreate={this.onContextCreate}
      />
    );
  }

Meshes code :

export const loadThreeJSTexture = (gl, src, texture, renderer) => {
  var properties = renderer.properties.get(texture);
  gl
    .getExtension('RN')
    .loadTexture({ yflip: true, image: src })
    .then(({ texture }) => {
      properties.__webglTexture = texture;
      properties.__webglInit = true;
      texture.needsUpdate = true;
    });
};

export const loadTexture = (gl, src, renderer) => {
  const texture = new THREE.Texture();
  const material = new THREE.MeshBasicMaterial({ map: texture, transparent: true, overdraw: 0.5 });
  loadThreeJSTexture(gl, src, texture, renderer);
  return material;
};

export const createBackground = (width, height, gl, renderer) => {
  const blueBackground = new THREE.BoxGeometry(width, height, 0);
  const material = loadTexture(gl, require('background.png'), renderer);
  const mesh = new THREE.Mesh(blueBackground, material);

  mesh.position.z = -40;

  return mesh;
};

export const createPlane = (gl, renderer) => {
  const geometry = new THREE.PlaneBufferGeometry(0.6, 1);
  const material = loadTexture(gl, require('plane.png'), renderer);
  const mesh = new THREE.Mesh(geometry, material);

  return mesh;
};

export const createStar = (width, x, y) => {
  const geometry = new THREE.CircleGeometry(width, 12);
  const material = new THREE.MeshBasicMaterial({color: 0xff0000});
  const mesh = new THREE.Mesh(geometry, material);

  mesh.position.x = x;
  mesh.position.y = y;
  mesh.position.z = -1;

  return mesh;
};

On the first render only, nothing appears but the red circle star.
Am I loading the textures incorrectly ?

iOS >= 100% cpu usage when textureLoad

Hi there,

I'm building a panorama image viewer for iOS at the moment. My problem is that when I load an panorama image my cpu usage jumps from ~5% to over 100% and never drops down.

I'm using this to load the image and create the sphere:

import THREE from './three'

export const loadThreeJSTexture = async (gl, src, texture, renderer) => {
  var properties = renderer.properties.get(texture)
  await gl.getExtension('RN')
    .loadTexture({ yflip: false, image: src })
    .then(({ texture }) => {
      properties.__webglTexture = texture
      properties.__webglInit = true
      texture.needsUpdate = true
      gl.flush()
      gl.getExtension('RN').endFrame()
    })
}

export const loadTexture = async (gl, src, renderer) => {
  const texture = new THREE.Texture()
  const material = new THREE.MeshBasicMaterial({map: texture, overdraw: 0.5})
  await loadThreeJSTexture(gl, src, texture, renderer)
  return material
}

export const createSphere = async (gl, pano, renderer) => {
  const geometry = new THREE.SphereBufferGeometry(500, 60, 40)

  const material = await loadTexture(gl, pano, renderer)
  const mesh = new THREE.Mesh(geometry, material)

  mesh.rotation.z = Math.PI

  return mesh
}

any ideas why my cpu usage is so high? Thank you in advance!

Attempt to read from field 'int fr.greweb.rnwebgl.RNWebGLTexture.ctxId' on a null object reference

I have a React Native component which uses react-native-webgl for rendering a game. This component can be unloaded via navigation and the user go back into it again.

During testing a Samsung S8 (Physical) and a Nexus 5 (Emulator) I had no issues, however deploying it to a Samsung S6 ends up throwing the above error after a few restarts of the game within the application.

My Game component (responsible for handling all the react-native-webgl has a 'componentWillUnmount' method which appears to get called each time the component is unloaded via React Native, as it should. In this method I am going through and deleting all my WebGL Textures, and then setting my this.gl variable to null (this is the object that was passed to the component on onContextCreate).

I presume that this error is being caused by some sort of race condition between React Native unloading the component, and RNWebGL doing it's cleanup.

I've attached a screenshot of the issue. Now I suspect a simple Null check in the Native code might avoid this issue happening, but I wan't to check that I shouldn't be cleaning up some other way, or if I might be missing something obvious

screen shot 2018-05-01 at 14 11 14

Error Compiling: Android NDK: android-9 is unsupported. Using minimum supported version android-14.

I get the following error:

image

The instrucctions says:

android/local.properties: Make sure you have an up-to-date Android NDK (needed to compile the Native C++ code) and that it's properly configured in ANDROID_NDK env or in local.properties file (e.g. ndk.dir=/usr/local/share/android-ndk).
android/build.gradle: if it's not already there, add gradle-download-task buildscript dependency: classpath 'de.undercouch:gradle-download-task:3.1.2' . If you don't do this, you will likely have :downloadJSCHeaders not working.
android/app/build.gradle: Make sure you have minSdkVersion 17 or higher

The above files are listed below:

android/local.properties:

image

**android/build.gradle: **

image

android/app/build.gradle:

image

My NDK file path is correct:

image

And my NDK version is not 9 as the error says but 16

image

Implement Renderbuffer support

these methods are not implemented

  • framebufferRenderbuffer
  • getFramebufferAttachmentParameter
  • bindRenderbuffer
  • createRenderbuffer
  • deleteRenderbuffer
  • getRenderbufferParameter
  • renderbufferStorage

Android black textures

As discussed here #16 , textures loaded with gl.getExtension('RN').loadTexture() sometimes fails to load on Android (rendering a black mesh)

export const loadThreeJSTexture = async (gl, src, texture, renderer) => {
  var properties = renderer.properties.get(texture);
  await gl.getExtension('RN')
    .loadTexture({ yflip: false, image: src })
    .then(({ texture }) => {
      properties.__webglTexture = texture;
      properties.__webglInit = true;
      texture.needsUpdate = true;
    });
};

export const loadTexture = async (gl, src, renderer) => {
  const texture = new THREE.Texture();
  const material = new THREE.MeshBasicMaterial({ map: texture, transparent: true, overdraw: 0.5 });
  await loadThreeJSTexture(gl, src, texture, renderer);
  return material;
};

export const createPlayer = async (gl, renderer) => {
  const geometry = new THREE.PlaneBufferGeometry(0.6, 1);
  const material = await loadTexture(gl, images.player, renderer);
  const mesh = new THREE.Mesh(geometry, material);

  mesh.material.side = THREE.DoubleSide;
  mesh.rotation.z = Math.PI;
  mesh.rotation.y = Math.PI;

  return mesh;
};

Error: bundling failed: ambiguous resolution

I am getting an when attempting to run the examples. From react-native-webgl\example I run
npm i --save
react-native run-android

I get this error

Bundling index.android.js [development, non-minified] 0.0% (0/1), failed.
error: bundling failed: ambiguous resolution: module ...\react-native-webgl\example\index.android.js tries to require react-native, but there are several files providing this module. You can delete or fix them:

  • ...\react-native-webgl\example\node_modules\react-native\package.json
  • ...\react-native-webgl\node_modules\react-native\package.json

I have tried this command as suggested on a few threads,

npm start -- --reset-cache

however I get the error:

Looks like you installed react-native globally, maybe you meant react-native-cli?

Any ideas how I might get the examples running?

RNWebGLView.java:50: error: cannot find symbol

I always got this error , when i build for android on windows ,

local.properties:

ndk.dir=E\:\\android\\android-ndk-r10d-windows-x86_64\\android-ndk-r10d

and settings.gradle:

`rootProject.name = 'swag'
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')

include ':app'
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')

include ':react-native-webgl'
project(':react-native-webgl').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webgl/android')

include ':RNWebGL'
project(':RNWebGL').projectDir = file('../node_modules/react-native-camera/android')`

build error:

`F:\rn\swag\swag\node_modules\react-native-webgl\android\src\main\java\fr\greweb
rnwebgl\RNWebGLView.java:50: error: cannot find symbol
ctxId = RNWebGLContextCreate(reactContext.getJavaScriptContext());
^
symbol: method getJavaScriptContext()
location: variable reactContext of type ReactContext
Note: F:\rn\swag\swag\node_modules\react-native-webgl\android\src\main\java\fr\g
reweb\rnwebgl\RNWebGLViewManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
:react-native-webgl:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':react-native-webgl:compileReleaseJavaWithJavac'.

Compilation failed; see the compiler error output for details.

  • Try:
    Run with --info or --debug option to get more log output.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':react-n
    ative-webgl:compileReleaseJavaWithJavac'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
    ecuteActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
    ecute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExec
    uter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.exec
    ute(SkipUpToDateTaskExecuter.java:66)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execut
    e(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecu
    ter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter
    .execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execut
    e(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter
    .execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTa
    skWorker.execute(DefaultTaskGraphExecuter.java:203)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTa
    skWorker.execute(DefaultTaskGraphExecuter.java:185)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
    orker.processTask(AbstractTaskPlanExecutor.java:66)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
    orker.run(AbstractTaskPlanExecutor.java:50)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(Defaul
    tTaskPlanExecutor.java:25)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(Defau
    ltTaskGraphExecuter.java:110)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTask
    ExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
    r.java:37)
    at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExec
    uter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecu
    ter.java:43)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildEx
    ecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
    r.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
    r.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLa
    uncher.java:153)
    at org.gradle.internal.Factories$1.create(Factories.java:22)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
    tBuildOperationExecutor.java:91)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
    tBuildOperationExecutor.java:53)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
    GradleLauncher.java:150)
    at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGra
    dleLauncher.java:32)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradl
    eLauncher.java:98)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradl
    eLauncher.java:92)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
    tBuildOperationExecutor.java:91)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(Defaul
    tBuildOperationExecutor.java:63)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradle
    Launcher.java:92)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLaun
    cher.java:83)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildCon
    troller.run(InProcessBuildActionExecuter.java:99)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(Exe
    cuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildA
    ctionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
    ssBuildActionExecuter.java:48)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
    ssBuildActionExecuter.java:30)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(Contin
    uousBuildActionExecuter.java:81)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(Contin
    uousBuildActionExecuter.java:46)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.exe
    cute(DaemonUsageSuggestingBuildActionExecuter.java:51)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.exe
    cute(DaemonUsageSuggestingBuildActionExecuter.java:28)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.jav
    a:173)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
    execute(CommandLineActionFactory.java:239)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.
    execute(CommandLineActionFactory.java:212)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRunti
    meValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRunti
    meValidationAction.java:24)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
    ortingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep
    ortingAction.java:22)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
    CommandLineActionFactory.java:205)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(
    CommandLineActionFactory.java:169)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBoots
    trap.java:55)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.j
    ava:36)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.ja
    va:30)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
    Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Com
    pilation failed; see the compiler error output for details.
    at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJava
    Compiler.java:48)
    at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJava
    Compiler.java:33)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegat
    eAndHandleErrors(NormalizingJavaCompiler.java:104)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute
    (NormalizingJavaCompiler.java:53)
    at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute
    (NormalizingJavaCompiler.java:38)
    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.exe
    cute(CleaningJavaCompilerSupport.java:35)
    at org.gradle.api.internal.tasks.compile.CleaningJavaCompilerSupport.exe
    cute(CleaningJavaCompilerSupport.java:25)
    at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilat
    ionFinalizer.execute(IncrementalCompilationFinalizer.java:39)
    at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilat
    ionFinalizer.execute(IncrementalCompilationFinalizer.java:24)
    at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompi
    le.java:163)
    at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:127
    )
    at com.android.build.gradle.tasks.factory.AndroidJavaCompile.compile(And
    roidJavaCompile.java:49)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
    actory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245)

      at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
    

actory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:61)
... 60 more

BUILD FAILED`

C++ compilation issues while building app on Android

Hi,
I've got the NDK installed and the classpath set for gradle-download-task, but when I try to build the app, I get an error from the NDK. This is the log: https://pastebin.com/4qFhKqXy.

I tried to follow the answer at https://stackoverflow.com/a/35178570/2848972, but I was unable to figure out what to do. I ran the following command thinking that it'd solve it, but there doesn't seem to be a change.
$ANDROID_NDK/build/tools/make_standalone_toolchain.py --archarm --api 14 --install-dir /tmp/my-android-toolchain

Could someone please help me with this issue?

Texture Loading Issues (iOS) (Three JS)

I get the following error when setting yflip to false on iOS:

Assertion failure in -[GPUImageFramebuffer unlock], /.../node_modules/react-native- webgl/ios/framework/Source/GPUImageFramebuffer.m:269

Examining line 269, the following assert is getting invoked:

NSAssert(framebufferReferenceCount > 0, @"Tried to overrelease a framebuffer, did you forget to call -useNextFrameForImageCapture before using -imageFromCurrentFramebuffer?");

Thus, textures do not display correctly. The issue does not occur if yflip is set to true on iOS. The exact same code runs fine on Android, irrespective of what value yflip is set to. At first, this error appeared to be the same as #16 but the scenario for when it does or does not work is reversed for me:

Value of yflip Issue on iOS
true No
false Yes

The load texture call that I make is as follows:

function loadTexture(data, src, flip) {
  let texture = new THREE.Texture();
  let properties = renderer.properties.get(texture);
  let material = new THREE.MeshBasicMaterial({map: texture, overdraw: 0.5});
  glex.loadTexture({ yflip: flip, image: src })
    .then(({ texture }) => {
      properties.__webglTexture = texture;
      properties.__webglInit = true;
      texture.needsUpdate = true;
    });
  return material;
}

Where glex = gl.getExtension('RN'), and flip is a boolean argument.

Am I perhaps missing something related to when yflip can be set to false? Or is there an issue currently with the implementation of yflip in react-native-webgl for iOS?

[Android] Build Gradle 3.0.1 Error

Hi,
after updating my Android Gradle to 3.0.1, i get this error when trying to compile:

screen shot 2018-04-07 at 18 55 54

Transcript:

FAILURE: Build failed with an exception.

* Where:
Build file '/Volumes/HDD2/GitHub/iazzu/app/node_modules/react-native-webgl/android/build.gradle' line: 91

* What went wrong:
Execution failed for task ':react-native-webgl:prepareJSC'.
> build_7tb59klnecztdru5rgs40s1kd$_run_closure3$_closure11

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 23s
554 actionable tasks: 554 executed

Please help! Thanks.

Invariant Violation: Native component for 'RNWebGLView' does not exist

Hello,

I'm trying to implement some WebGL code within a React Native application and I'm stumbling at the first hurdle.

I've tried to follow the instructions in the README about how to set up the React Native application to support the react-native-webgl Component but I am very new t React Native so suspect I'm doing something very silly and simple to fix but I'm just not sure where to look. Any help would be appreciated.

When testing the React Native application either on my Android phone or an Android Emulator I am receiving the following error and stack trace:

`Invariant Violation: Native component for "RNWebGLView" does not exist

This error is located at:
in RNWebGLView (created by WebGLView)
in RCTView (at View.js:78)
in View (created by WebGLView)
in WebGLView (at Game.js:14)
in Game (at App.js:8)
in App (at registerRootComponent.js:35)
in RootErrorBoundary (at registerRootComponent.js:34)
in ExpoRootComponent (at renderApplication.js:35)
in RCTView (at View.js:78)
in View (at AppContainer.js:102)
in RCTView (at View.js:78)
in View (at AppContainer.js:122)
in AppContainer (at renderApplication.js:34)`

Are there any additional steps after the README steps that I need to do to make this component available to the build process?

add a onFrame callback prop

this was mentioned in gl-react gitter chat by @tomduncalf : the GLView should have a onFrame callback. that would allow us to pace the call at the correct framerate and avoid potential glitches we seem to currently have (like double time drawing the same frame / slow issues)

so basically you would have onContextCreate allowing to init things with the GL context and then a onFrame callback that allows you to draw things continuously.
if you don't need to do continuous animations you would simply not give such a callback (or just a noop function should be fine)

Attempt to invoke virtual method 'boolean fr.greweb.rnwebgl.RNWebGLTexture.listenAttached(java.lang.Runnable)' on a null object reference

Hi, i got this the following error on version 3.15.0:

    java.lang.NullPointerException: Attempt to invoke virtual method 'boolean fr.greweb.rnwebgl.RNWebGLTexture.listenAttached(java.lang.Runnable)' on a null object reference
        at fr.greweb.rnwebgl.RNWebGLTextureLoader$2.call(RNWebGLTextureLoader.java:67)
        at fr.greweb.rnwebgl.RNWebGLTextureLoader$1.call(RNWebGLTextureLoader.java:57)
        at fr.greweb.rnwebgl.RNWebGLTextureImageLoader$1.onFailureImpl(RNWebGLTextureImageLoader.java:71)
        at com.facebook.datasource.BaseDataSubscriber.onFailure(BaseDataSubscriber.java:59)
        at com.facebook.datasource.AbstractDataSource$1.run(AbstractDataSource.java:177)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:43)
        at java.lang.Thread.run(Thread.java:764)

How to achieve randomness for 2D noise function

Hello! Thanks for the wonderful library!

I am implementing a film grain image effect, and it involves a noise function and the below 2D random function (taken from book of shaders). I was able to implement the effect nicely in webgl, but when using react-native-webgl, the randomness and noise functions both had unexpected and very different outputs than webgl. The following shader:

float random(vec2 co){
  return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}

void main() {
  float rnd = random(v_position);

  gl_FragColor = vec4(vec3(rnd), 1.0);
}

Outputed:
webgl

In webgl, but in react-native-webgl outputed:
rnwebgl
(which does not appear very random). I am wondering why the output is so inconsistent between the two platforms, if the difference can be remedied, or if it is a hardware problem... Any advice would be greatly appreciated!

iOS: Archiving fails

So my app using this awesome package runs fine in debug mode, in simulator and on a device.

Soon as I wanna create an archive in XCode, I get this error:

screen shot 2018-03-16 at 10 30 45

Showing All Issues
While trying to resolve module react-native-webgl from file /Volumes/HDD2/GitHub/iazzu/app/src/view/components/gl/CGLTest/CGLTest_app.js, the package /Volumes/HDD2/GitHub/iazzu/app/node_modules/react-native-webgl/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/Volumes/HDD2/GitHub/iazzu/app/node_modules/react-native-webgl/lib/index.js. Indeed, none of these files exist:
/Volumes/HDD2/GitHub/iazzu/app/node_modules/react-native-webgl/lib/index.js(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)
(....)

Which kinda makes sense, since the file lib/index.js doesn't exist, it's in the src/ folder. Soon as I changed the react-native-webgl's package.json file, archiving worked:

- "main": "lib/index.js",
+ "main": "src/index.js"

Just in case anybody wants to use this in an actual production project and runs into this issue too :) Kudos for this awesome package btw.

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.