この「一般の話題」の
https://www.jogrid.net/wi/mod/forum/discuss.php?d=571
https://www.jogrid.net/wi/mod/forum/discuss.php?d=594
で話題にしたSVG(Scalable Vector Graphics)は、説明パネルなどでフォントサイズや文字の位置をインワールドで編集できる便利なものです。
Firestormで日本語が文字化けするのを修正したものを知世さんが作ってくれたのですが、以下のデータだとエラーが出ます(元のバージョンでは正常表示)。tspanを使わないデータではエラーは出ないです。
-------SVGデータ------------------------
<svg xmlns="http://www.w3.org/2000/svg">
<text x="100" y="100" style="font-family:Arial;font-weight:bold;font-size:70px">Step 1 Introduction</text>
<text x="90" y="200" style="font-family:Arial;font-size:30px">
<tspan x="90" dy="36">- Preliminary survey to measure attitude toward usability of VWs</tspan>
<tspan x="110" dy="36">for special education</tspan>
<tspan x="90" dy="60">- Brainstorm on questions about VWs </tspan>
<tspan x="90" dy="60">- Watch educational VW videos</tspan>
<tspan x="90" dy="60">- Hands-on training incl. special features</tspan>
<tspan x="90" dy="60">- Special affordances for students with social skills challenges.</tspan>
<tspan x="90" dy="60">- Teacher resources specifically designed for special education,</tspan>
<tspan x="110" dy="36">incl. access to pretested destinations categorized according</tspan>
<tspan x="110" dy="36">to age groups and subject matter</tspan>
<tspan x="90" dy="60">- How to locate age-appropriate and subject-related destinations</tspan>
</text></svg>
-------SVGスクリプト--------------------
integer hudface = 4;//non rotate cube hud viewrable face is 4.
// :CATEGORY:Viewer 2
// :NAME:SVG_Scalable_Vector_Graphics_in_Sha
// :AUTHOR:Pavcules Superior
// :CREATED:2010-09-02 12:04:07.130
// :EDITED:2013-09-18 15:39:05
// :ID:853
// :NUM:1183
// :REV:1.0
// :WORLD:Second Life
// :DESCRIPTION:Example website: http://tutorials.jenkov.com/svg/index.html
//
// The demo script below, adapted from the Notecard on a Prim script, reads a notecard with SVG elements and puts it in the URL. This is limited to 1024 characters. Remember to create a notecard inside the prim for this to work.
//
// Unfortunately, SVG is more trickier to handle when trying to embed it into a web page via the same prim. Using the other techniques like Ajax to increase the size is running into problems. To embed SVG into a page requires the use of the Object / Embed tags. It has no problems linking to an external website with the SVG file. But trying to reference a prim via HTTP-In to get the SVG code, is not working at all. The only way around that I can see would be to have IFrames and embed the "Data:image/svg+xml" Mime type encoding of the SVG in the Iframe source path.
// :CODE:
// SVG on a Prim
// Developed by: Pavcules Superior
// Developed on: March 2010
string g_strNotecardName;
string g_strNotecardText;
integer g_intNotecardLine = 0;
key g_keyNotecardQueryID;
key g_keyURLRequestID;
// Start reading the notecard text.
ReadNotecardText()
{
llOwnerSay("Reading Notecard...please wait.");
g_intNotecardLine = 0;
g_strNotecardText = "";
g_strNotecardName = llGetInventoryName(INVENTORY_NOTECARD, 0);
g_keyNotecardQueryID = llGetNotecardLine(g_strNotecardName, g_intNotecardLine);
// Change the URL
string dataUri = "data:text/plain,Loading Page...Please Wait..." + (string)llGetUnixTime();
llSetPrimMediaParams(hudface,[ PRIM_MEDIA_CURRENT_URL, dataUri]);
}
default
{
state_entry()
{
ReadNotecardText();
g_keyURLRequestID = llRequestURL();
}
changed(integer change)
{
// If the inventory is updated, read the notecard data again.
if(change & CHANGED_INVENTORY)
{
ReadNotecardText();
}
}
dataserver(key query_id, string data)
{
if (query_id == g_keyNotecardQueryID)
{
if (data != EOF)
{
// Store the text.
g_strNotecardText += data;
// Read next notecard line.
++g_intNotecardLine;
g_keyNotecardQueryID = llGetNotecardLine(g_strNotecardName, g_intNotecardLine);
}
else
{
// We have reached the end of the notecard.
llOwnerSay("Size: " + (string)llStringLength(g_strNotecardText));
llOwnerSay("Rendering Media image...please wait.");
// Refresh the URL again by setting a random URL parameter value.
string dataUri = "data:image/svg+xml;charset=UTF-8," + g_strNotecardText;
//ここでUTF-8が表示されるように指定。
llSetPrimMediaParams(hudface,
[PRIM_MEDIA_AUTO_PLAY,TRUE,
PRIM_MEDIA_HOME_URL,dataUri,
PRIM_MEDIA_CURRENT_URL,dataUri,
PRIM_MEDIA_HEIGHT_PIXELS,1024,
PRIM_MEDIA_WIDTH_PIXELS,1024]);
}
}
}