forked from PixarAnimationStudios/OpenSubdiv
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwasm_demo.html
More file actions
126 lines (120 loc) · 3.83 KB
/
Copy pathwasm_demo.html
File metadata and controls
126 lines (120 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OpenSubdiv WASM Demo</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
.container {
background: #f5f5f5;
padding: 20px;
border-radius: 8px;
margin: 20px 0;
}
pre {
background: #333;
color: #fff;
padding: 15px;
border-radius: 4px;
overflow-x: auto;
}
button {
background: #007cba;
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background: #005a87;
}
.output {
background: white;
border: 1px solid #ddd;
padding: 15px;
border-radius: 4px;
margin-top: 10px;
}
</style>
</head>
<body>
<h1>OpenSubdiv WASM Demo</h1>
<div class="container">
<h2>CPU-Only WebAssembly Build</h2>
<p>This demonstrates OpenSubdiv's CPU-only subdivision algorithms running in WebAssembly.</p>
<p>The demo creates a simple cube mesh and performs 2 levels of Catmull-Clark subdivision.</p>
<button onclick="runSubdivision()">Run Subdivision Test</button>
<div id="output" class="output" style="display:none;">
<h3>Output:</h3>
<pre id="result"></pre>
</div>
</div>
<div class="container">
<h2>Technical Details</h2>
<ul>
<li><strong>Library:</strong> OpenSubdiv v3.6.1</li>
<li><strong>Build Type:</strong> CPU-only WASM build</li>
<li><strong>Subdivision Scheme:</strong> Catmull-Clark</li>
<li><strong>Input:</strong> 8 vertices, 6 faces (cube)</li>
<li><strong>Refinement Levels:</strong> 2</li>
<li><strong>Expected Output:</strong> 132 vertices, 126 faces</li>
</ul>
</div>
<div class="container">
<h2>Build Configuration</h2>
<p>This WASM build was configured with the following CMake flags:</p>
<pre>emcmake cmake -B wasm-cpu-build \
-DCMAKE_BUILD_TYPE=Release \
-DNO_EXAMPLES=1 \
-DNO_TUTORIALS=1 \
-DNO_REGRESSION=1 \
-DNO_DOC=1 \
-DNO_OPENGL=1 \
-DNO_METAL=1 \
-DNO_DX=1 \
-DNO_CUDA=1 \
-DNO_OPENCL=1 \
-DNO_CLEW=1 \
-DNO_OMP=1 \
-DNO_TBB=1 \
-DNO_PTEX=1 \
-DNO_GLFW=1 \
-DNO_GLEW=1 \
-DBUILD_SHARED_LIBS=OFF \
-S .</pre>
</div>
<script>
let outputDiv = document.getElementById('output');
let resultPre = document.getElementById('result');
// Capture console output
let capturedOutput = '';
const originalLog = console.log;
console.log = function(...args) {
capturedOutput += args.join(' ') + '\n';
originalLog.apply(console, arguments);
};
function runSubdivision() {
capturedOutput = '';
outputDiv.style.display = 'block';
resultPre.textContent = 'Loading and running subdivision test...';
// Import and run the WASM module
import('./wasm_test.js').then(module => {
// The module should automatically run main() and produce output
setTimeout(() => {
resultPre.textContent = capturedOutput || 'Subdivision test completed successfully!';
}, 100);
}).catch(error => {
resultPre.textContent = 'Error: ' + error.message;
});
}
</script>
</body>
</html>