-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ai-model to for text to 3D model generation
- Loading branch information
Showing
8 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Anchor (Mixed Reality) • A-Frame</title> | ||
<meta name="description" content="Anchor (Mixed Reality) • A-Frame"> | ||
<script src="../../../dist/aframe-master.js"></script> | ||
<script src="../../js/info-message.js"></script> | ||
</head> | ||
<body> | ||
<a-scene | ||
info-message="htmlSrc: #messageText"> | ||
<a-assets> | ||
<a-asset-item id="messageText" src="message.html"></a-asset-item> | ||
</a-assets> | ||
<a-entity ai-model></a-entity> | ||
</a-scene> | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<p> | ||
This demo requires a browser supporting the <a href="https://immersive-web.github.io/anchors/">WebXR Anchors Module</a> | ||
</p> | ||
|
||
<p> | ||
In AR mode the user can pinch to grab the painting and release it at any position and orientation. The painting will remain anchored to the real world coordinate where it was released by the user. The anchor will persists upon page reload. | ||
</p> | ||
|
||
<p> | ||
Paintings by <a href="https://en.wikipedia.org/wiki/Vincent_van_Gogh">Van Gogh</a>, <a href="https://en.wikipedia.org/wiki/Alphonse_Mucha">Alphonse Mucha</a>, <a href="https://en.wikipedia.org/wiki/El_Greco">El Greco</a> and <a href="https://en.wikipedia.org/wiki/Edvard_Munch">Edvard Munch</a>. Frame model by <a href="https://sketchfab.com/3d-models/vintage-painting-dani-3fdd92904c2b44028bef28b33e897d9f">theGentleGiant</a> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var registerComponent = require('../core/component').registerComponent; | ||
var GRADIOCLIENT = require('../lib/gradio'); | ||
|
||
/** | ||
* AI model loader. | ||
*/ | ||
module.exports.Component = registerComponent('ai-model', { | ||
schema: { | ||
prompt: {type: 'string', default: 'robot'}, | ||
api: {type: 'string', oneOf: ['perflow']}, | ||
key: {type: 'string', default: ''} | ||
}, | ||
|
||
init: function () { | ||
this.generateAndRender(this.data.prompt); | ||
}, | ||
|
||
update: function () { | ||
|
||
}, | ||
|
||
generateAndRender: async function generateAndRender (prompt) { | ||
var modelEl = document.createElement('a-entity'); | ||
modelEl.setAttribute('position', '0 1.6 -2'); | ||
modelEl.setAttribute('rotation', '0 180 0'); | ||
var app = await GRADIOCLIENT('hansyan/perflow-triposr', {}); | ||
var result = await app.predict( | ||
'/render', | ||
(await app.predict('/generate', [prompt, '0'])).data | ||
); | ||
console.log('Model URL: ' + result.data[0].url); | ||
modelEl.setAttribute('obj-model', {obj: result.data[0].url}); | ||
this.el.sceneEl.appendChild(modelEl); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
require('./ai-model'); | ||
require('./animation'); | ||
require('./anchored'); | ||
require('./camera'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var GRADIOCLIENT = require('./gradio.module.js').default; | ||
|
||
module.exports = GRADIOCLIENT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { client } from '@gradio/client'; | ||
|
||
var GRADIOCLIENT = client; | ||
|
||
export default GRADIOCLIENT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters