1.1.8 • Published 5 years ago

ff-3d-preview v1.1.8

Weekly downloads
-
License
-
Repository
github
Last release
5 years ago

What is ff-3d-preview

ff-3d-preview is a package to easily add 3d rendering to a HTML5 canvas with a 3d model with a face with an image.
The package uses Three.JS, has a .gltf loader and orbit-controls implemented.

An example:
alt text

How do I use ff-3d-preview?

Install the package using:
npm install ff-3d-preview

Using ff-3d-preview

3D thumbnail render (returns base64) example

 const thumbnail3DRenderer = new FF3DPreview();
 thumbnail3DRenderer.FFGenerate3DThumbnail(canvas, gltfModel);  

3D preview rendering with animation loop example

let frameId = -1;

(async function () {
    const renderFrame = await load3DPreview(canvasRef.current, sheetIndex);
    setLoading(false);
    (function animationLoop() {
        renderFrame();
        frameId = requestAnimationFrame(animationLoop);
    }());
}());

return () => {
    cancelAnimationFrame(frameId);
};

In load3DPreview function:

const thumbnail3DRenderer = new FF3DPreview();
return await thumbnail3DRenderer.FFRender3DPreviewFrame(previewImageCanvas.toDataURL(), gltfModel, previewCanvas);

Prerequisites 3D model

The 3D model has a few prerequisites in order to work with this package.

  • .gltf extension.
  • There needs to be a face called PreviewMesh in the root of the model where the image will be placed.
  • PreviewMesh will be transparent so placing a face below PreviewMesh is advised.
  • In order to use reflections (using a cube-map), give the face the name ReflectionMesh.

This package is brought to you by:
alt text

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago