-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a0b141
commit baec7ab
Showing
2 changed files
with
50 additions
and
43 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 |
---|---|---|
|
@@ -2,49 +2,38 @@ | |
<html lang="ja"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<script src="https://unpkg.com/@xpadev-net/[email protected]/dist/bundle.js"></script> | ||
<script src="https://unpkg.com/@xpadev-net/[email protected]/dist/bundle.js"></script> | ||
<script src="https://xpadev-net.github.io/niwango.js/niwango.js"></script> | ||
</head> | ||
<body> | ||
<canvas id="canvas" width="1920" height="1080"></canvas> | ||
<div id="loading">読み込み中...</div> | ||
</body> | ||
<script> | ||
let niwango,interval=0,currentTime=0,videoMicroSec=false; | ||
let nico,interval=0,currentTime=0,videoMicroSec=false,cursorPos={x:0,y:0}; | ||
const canvasElement = document.getElementById("canvas"); | ||
const updateCanvas = () => { | ||
if (!niwango) return; | ||
const vpos = () => { | ||
if (!videoMicroSec) { | ||
niwango.draw(Math.floor(currentTime * 100)); | ||
} else { | ||
niwango.draw( | ||
Math.floor( | ||
(performance.now() - videoMicroSec.microsec) / 10 + | ||
videoMicroSec.currentTime * 100 | ||
) | ||
); | ||
return Math.floor(currentTime * 100); | ||
} | ||
return Math.floor( | ||
(performance.now() - videoMicroSec.microsec) / 10 + | ||
videoMicroSec.currentTime * 100 | ||
); | ||
} | ||
const updateCanvas = () => { | ||
if (!nico) return; | ||
nico.drawCanvas(vpos(),true,cursorPos); | ||
}; | ||
const init = (threads) => { | ||
const init = (data) => { | ||
document.getElementById("loading").remove(); | ||
const comments = []; | ||
for (const thread of threads){ | ||
for (const comment of thread.comments){ | ||
comments.push({ | ||
message: comment.body, | ||
vpos: Math.floor(comment.vposMs/10)/100, | ||
isYourPost: comment.isMyPost, | ||
mail: comment.commands.join(" "), | ||
fromButton: false, | ||
color: 0, | ||
size: 0, | ||
no: comment.no, | ||
_vpos: Math.floor(comment.vposMs/10), | ||
_owner: thread.fork === "owner" | ||
}); | ||
} | ||
} | ||
|
||
niwango=new Niwango(canvasElement,comments) | ||
nico = new NiconiComments(canvasElement, data, { | ||
format: "v1", | ||
config: { | ||
plugins: window.PluginNiwango ? [window.PluginNiwango(window.Niwango)] : [], | ||
}, | ||
}); | ||
if (!interval){ | ||
interval = setInterval(updateCanvas, 1); | ||
} | ||
|
@@ -85,6 +74,21 @@ | |
setTimeout(()=>element.remove(),5000); | ||
} | ||
} | ||
canvasElement.onmousemove = (e) => { | ||
cursorPos = { | ||
x: e.offsetX * (canvasElement.width / canvasElement.clientWidth), | ||
y: e.offsetY * (canvasElement.height / canvasElement.clientHeight), | ||
} | ||
} | ||
canvasElement.onmouseout = () => { | ||
cursorPos = undefined; | ||
} | ||
canvasElement.onclick = (e) => { | ||
nico.click(vpos(),{ | ||
x: e.offsetX * (canvasElement.width / canvasElement.clientWidth), | ||
y: e.offsetY * (canvasElement.height / canvasElement.clientHeight), | ||
}); | ||
} | ||
</script> | ||
<style> | ||
*{ | ||
|
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