-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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 component for text to 3D model generation
- Loading branch information
Showing
9 changed files
with
101 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
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>AI Model • 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,3 @@ | ||
<p> | ||
This demo illustrates how to integrate text to 3D in A-Frame</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