Giter Club home page Giter Club logo

a-frame-component-simplify-modifier's Introduction

A-Frame-Component: Simplify-Modifier

Video screen capture

Description / Rationale

This is A-Frame component for simplification of GLTF meshes. It is the adaptation of similar example made in Three.js with additional features:

  • Simplification of multiple gltf meshes
  • Assigning color to simplified mesh
  • Enabling wireframe of simplified mesh.

Instructions

In order to use the component attach "simplify-modifier" to a-entity with gltf-model component. The component has the following attributes:

  • color: { type: 'color', default: '#ffffff' } - Color of the simplified mesh
  • wireframe: { type: 'boolean', default: false } - Whether to show wireframe of simplified mesh or not
  • count: { type: 'number', default: 0.7 } - Vertices to remove. Accepts values from 0 to 1. 0 - almost no simplifaction is made. 1 - complete simplification. Please note that if 1 is selected, mesh will not be visible.
  • offset: { type: 'number', default: 1 } - Offset of simplified mesh on x-axis. If 0 is selected, it will be in the same position as original GLTF model.

The code below shows the sample implementation of the component:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>A-Frame Component: Simplify Modifier</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <script src="https://aframe.io/releases/1.4.2/aframe.min.js"></script>
    <script src="js/simplifymodifier-component.js"></script>
</head>
<body>
    <a-scene>
        <a-entity simplify-modifier="color: lightblue" gltf-model="3d/LeePerrySmith.glb" position="-1 1.5 -2" rotation="0 0 0" scale="0.2 0.2 0.2" scale="0.01 0.01 0.01"></a-entity>
        <a-sky color="#000"></a-sky>
    </a-scene>
</body>
</html>

Please not that meshes without textures are only supported. When doing simplification if mesh is not visible, try to decrease the count value.

Tech Stack

The project is powered by AFrame and Three.js. The 3d model (gltf file) was taken from Three.js repository.

Demo

See demo of the component here: Demo

a-frame-component-simplify-modifier's People

Contributors

akbartus avatar

Watchers

 avatar

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.